• Plugins
  • Support
  • Blog
  • About
  • FAQ
Menu
  • Plugins
  • Support
  • Blog
  • About
  • FAQ
$0.00 0 Cart

Hooks that Stock Sync Monitors

Plugin: WooCommerce Stock Sync Pro

Stock Sync uses the following actions to monitor stock changes:

woocommerce_product_set_stock
woocommerce_variation_set_stock

These actions have to be triggered in order for Stock Sync to detect stock changes and synchronize them. The hooks are automatically run by WooCommerce itself and most other 3rd party plugins. However, if you have developed a custom solution that updates stock quantities, make sure to trigger the actions appropriately.

Technically the plugin works similarly for both products and variations so you can only trigger woocommerce_product_set_stock if you don’t know the product type.

Code that won’t work:

function update_quantity( $product, $stock_quantity ) {
  update_post_meta( $product->get_id(), '_stock', $stock_quantity );
}

This code won’t work because it doesn’t trigger the action after it has changed stock quantity.

Code that works with Stock Sync:

function update_quantity( $product, $stock_quantity ) {
  update_post_meta( $product->get_id(), '_stock', $stock_quantity );
  do_action( 'woocommerce_product_set_stock', $product );
}

This will work because it triggers woocommerce_product_set_stock.

« Back to docs
« Back to plugin
30 DAY MONEY BACK GUARANTEE
+6000 HAPPY CUSTOMERS
SUPPORT FROM THE DEVELOPER

WP Trio / BitBot Oy
Flätbackantie 1, 04150 Sipoo
FINLAND
VAT ID: FI28269925

WP Trio

  • Support
  • Blog
  • About
  • FAQ
  • My account
  • Support
  • Blog
  • About
  • FAQ
  • My account

Plugins

  • Plugins
  • Docs
  • Plugins
  • Docs