WordPress action hook

woocommerce_low_stock

Defined by WooCommerce and fired by 6 plugins in total, running on 7M+ sites between them.

“Action to signal that the value of 'stock_quantity' for a product is about to change.”

How to use woocommerce_low_stock

It's an action: your callback runs at that point and receives 1 argument. Nothing needs to be returned. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_action( 'woocommerce_low_stock', function( $product ) {
	// Your code runs here.
}, 10, 1 );

Argument names come from WooCommerce's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

6 plugins that fire woocommerce_low_stock

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. WooCommerce icon WooCommerce7+ million installs do_action( 'woocommerce_low_stock', wc_get_product( $change['product']->get_id() ) ) includes/wc-stock-functions.php:285
  2. ATUM WooCommerce Inventory Management and Stock Tracking icon ATUM WooCommerce Inventory Management and Stock Tracking10,000+ installs do_action( 'woocommerce_low_stock', wc_get_product( $change['product']->get_id() ) ) classes/Inc/Hooks.php:1301
  3. WholesaleX icon WholesaleX2,000+ installs do_action( 'woocommerce_low_stock', wc_get_product( $change['product']->get_id() ) ) includes/class-wholesalex-product.php:914
  4. BjornTech PayPal POS integration for WooCommerce icon BjornTech PayPal POS integration for WooCommerce600+ installs do_action( 'woocommerce_low_stock', wc_get_product( $product_id ) ) includes/izettle-stock-level-handler.php:215
  5. BjornTech Fortnox Hub for WooCommerce icon BjornTech Fortnox Hub for WooCommerce300+ installs do_action( 'woocommerce_low_stock', $product ) includes/class-woo-fortnox-hub-fn-product-handler.php:1292
  6. BundleBoss icon BundleBoss80+ installs do_action( 'woocommerce_low_stock', $fresh ) includes/orders.php:734

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.