Hubspot Integration
-
If you are using MakeWebBetter’s “MWB HubSpot for WooCommerce” plugin to sync your order’s data into HubSpot, then a common requirement is to push tracking information as soon as order is shipped.
This topic provides sample code to automatically push tracking information into HubSpot as soon as they are available in woocommerce.
Step 1. Create custom Deal properties on HubSpot.
Since HubSpot does not provide shipment related properties in Deals, we need to create custom properties by going to “Manage Properties” link and then clicking “Create Property”. See this screenshotStep 2: Add custom code to call hubspot’s api when awb number is available:
Add these lines of code into your theme’s function.php or anywhere else you prefer:add_action('bt_shipment_status_changed','hubspot_bt_shipment_status_changed',10,3); function hubspot_bt_shipment_status_changed($order_id,$shipment_obj,$bt_shipment_tracking_old){ if(class_exists('HubWooConnectionMananager')){ $connection_instance=HubWooConnectionMananager::get_instance(); if($connection_instance==null){ //nothing to do... return; } $deal_id = get_post_meta($order_id,'hubwoo_ecomm_deal_id',true); if(empty($deal_id)){ //nothing to do... return; } //shipment data: $courier_name = $shipment_obj->courier_name; $current_status = $shipment_obj->current_status; $awb = $shipment_obj->awb; $tracking_url = $shipment_obj->tracking_url; //create array for hubspot: $deal_property = array( "properties"=>array( array("name"=>"shipment_awb","value"=>$awb), //uncomment below lines as needed.... //array("name"=>"shipment_courier_name","value"=>$courier_name), //array("name"=>"shipment_current_status","value"=>$current_status), //array("name"=>"shipment_tracking_url","value"=>$tracking_url), ) ); $resp=HubWooConnectionMananager::get_instance()->update_existing_deal($deal_id,$deal_property); //echo json_encode($resp);exit; //uncomment to debug } }Feel free to modify the code as per your needs.
Shipment information should be automatically getting synced now.
See this screenshot for example.
The topic ‘Hubspot Integration’ is closed to new replies.