linksync for WooCommerce version 2.5.1 introduce four hooks after syncing so you could execute any additional code after sync happens.
HOOK NAME | DESCRIPTION |
ls_after_vend_to_woo_product_sync | This hook fires when there are product updates from vend and product syncing type is Vend to WooCommerce or Two-way sync. This hook also fires when you click trigger sync under linksync configuration tab and when you click sync reset under product syncing settings. Please see the examples below. |
ls_after_woo_to_vend_product_sync | This hook fires when the product from WooCommerce was sync to Vend. This will only fire when your product syncing type is Two-way or WooCommerce to Vend.Please see the examples below. |
ls_after_woo_to_vend_order_sync | This hook fires when you have order syncing settings enable and order syncing type is WooCommerce to Vend. Please note that order will sync depending on the selected WooCommerce Order status and WooCommerce orders will only be sync to Vend once. Please see the examples below. |
ls_after_vend_product_deletion | This hook will trigger if you have enable delete option under product syncing settings and your product sync type is Two-way and WooCommerce to Vend. Please see the examples below. |
Examples
Hook Name: ls_after_vend_to_woo_product_sync
Parameters: There are three possible parameters to be used.
$wooProductId - WooCommerce product ID.
$product - Is an instance of LS_Product and its main use is to parse json product into an accessible method to get Vend product details
$is_new - Whether this is an existing product being updated which is false or this product was created by linksync syncing which is true.
add_action('ls_after_vend_to_woo_product_sync', 'after_vend_to_woo_product_sync', 10, 3);
function after_vend_to_woo_product_sync($wooProductId, $product, $is_new){
//Execute your custom code here
// If you need to add a custom field and value of the product you could
// also be added here using$wooProductId
}
Hook Name: ls_after_woo_to_vend_product_sync
Parameters: There are three possible parameters to be used.
$wooProductId - WooCommerce product ID.
$json_product - Is an instance of LS_Json_Product_Factory and its main use is to build the json product to be used in creating or saving product in Vend.
$response - This is the response in from linksync server when saving the product in vend.
add_action('ls_after_woo_to_vend_product_sync', 'after_woo_to_vend_product_sync', 10, 3);
function after_woo_to_vend_product_sync($wooProductId, $json_product, $response){
//Execute your custom code here
// If you need to save custom field here you could ues $wooProductId
}
Hook Name: ls_after_woo_to_vend_order_sync
Parameters: There is one possible parameter to be used.
$order_id - This is the order id in WooCommerce of the order being sent to vend
add_action('ls_after_woo_to_vend_order_sync', 'after_woo_to_vend_order_sync', 10, 1);
function after_woo_to_vend_order_sync($order_id){
//Execute your custom code here
}
Hook Name: ls_after_vend_product_deletion
Parameters: There is one possible parameter to be used.
$delete_response - Is the response from linksync server when product delete request to vend was sent.
add_action('ls_after_vend_product_deletion', 'after_vend_product_deletion', 10, 1);
function after_vend_product_deletion($delete_response){
//Check $delete_reponse if product in vend was successfully deleted
}
Comments
0 comments
Please sign in to leave a comment.