Trigger process when a product is moved from *out of stock* to *in stock* in WooCommerce

245 Views Asked by At

I need to trigger a process when a product is moved from out of stock to in stock. I've played with a number of hooks:

  • woocommerce_reduce_order_stock
  • woocommerce_product_set_stock
  • woocommerce_variation_set_stock
  • woocommerce_product_before_set_stock
  • woocommerce_variation_before_set_stock

But none of the following hooks gives access to the previous stock to allow triggering only when moving from no stock to positive stock (which is why this case is unique).

I need to catch this when a product is changed by admin, API, or another process (refunded orders, etc.)

Is there a reliable hook or method for achieving this trigger?


Note: next question is related to my question: Which hook(s) are triggered when WooCommerce product stock is updated, but as described earlier in my question the hooks mentioned in the answers do not suffice.

0

There are 0 best solutions below