WordPress action hook
woocommerce_variation_set_stock_status
Defined by WooCommerce and fired by 6 plugins in total, running on 7M+ sites between them.
“Action to signal that the `stock_status` for a variation has changed.”
How to use woocommerce_variation_set_stock_status
It's an action: your callback runs at that point and receives 3 arguments. Nothing needs to be returned.
Add this to your theme's functions.php or a small custom plugin:
add_action( 'woocommerce_variation_set_stock_status', function( $event, $arg2, $product ) {
// Your code runs here.
}, 10, 3 );Argument names come from DataFeedWatch Connector for WooCommerce's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
6 plugins that fire woocommerce_variation_set_stock_status
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
WooCommerce7+ million installs
do_action( 'woocommerce_variation_set_stock_status', $product->get_id(), $product->get_stock_status(), $product )includes/data-stores/class-wc-product-data-store-cpt.php:972 -
Stock Locations for WooCommerce900+ installs
do_action( 'woocommerce_variation_set_stock_status', $product_id, $status, $product )src/helpers/helper-slw-product.php:196 -
DataFeedWatch Connector for WooCommerce600+ installs
do_action( 'woocommerce_variation_set_stock_status', $event['entity_id'], $product->get_stock_status(), $product )bridge2cart/bridge.php:1526 -
Api2Cart Bridge Connector40+ installs
do_action( 'woocommerce_variation_set_stock_status', $event['entity_id'], $product->get_stock_status(), $product )bridge2cart/bridge.php:1526 -
AutoSync WC Connect10+ installs
do_action( 'woocommerce_variation_set_stock_status', $id, $row['status'], $product )autosync-wc-connect.php:930 -
BeziworldFewer than 10 installs
do_action( 'woocommerce_variation_set_stock_status', $id, $status, $product )src/services/class-stock-updater.php:492
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.