Update stock programmatically
-
Hello,
I’m trying to update variable product stocks through php with this function:
wc_update_product_stock($post_id, $qty, ‘set’, false);
But I sometimes end up with the stock status showing “Out of stock (3)” – so it has stock but it shows the wrong status.I believe it doesn’t updated the stock status when it goes back in stock from 0.
I also tried:
wc_update_product_stock($post_id, $qty, ‘set’, true);
but it still didn’t work.How can I tell it to update the stock status? Is there a better way to quickly update stocks programmatically on multiple products through a cron job?
Thank you!
WooCommerce Version 4.0.1
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Update stock programmatically’ is closed to new replies.