woocommerce/plugins
Corey McKrill ad94888ce3
Ensure stock change notifications only fire when necessary (#51001)
* Ensure stock change notifs only fire when necessary

In #49583 we changed when the actions that trigger stock change
notifications fire, to decouple them from order creation. However, it
turns out what during product creation, the stock quantity update
routines still run even when no stock is being set and even when the
"manage stock" setting is set to false. Rather than try to untangle the
web of why this happens (and potentially break other things in the
process), this simply adds a check for the "manage stock" setting prior
to firing the notif actions, and bail early if the product does not have
managed stock.

It also adds a unit test, which is really more of an integration test,
to ensure this behavior.

Fixes #50958

* Remove irrelevant doc block info

In #49583 we added a second parameter to the
`woocommerce_variation_set_stock` and `woocommerce_product_set_stock`
action hooks, but it was later removed. However, we didn't remove the
corresponding doc block info.

* Add changelog file

---------

Co-authored-by: Naman Malhotra <naman03malhotra@gmail.com>
2024-08-29 17:11:38 +07:00
..
woo-ai Fix typos. (#50047) 2024-08-23 18:26:09 +01:00
woocommerce Ensure stock change notifications only fire when necessary (#51001) 2024-08-29 17:11:38 +07:00
woocommerce-admin CYS: Fix bottom margin of last patterns (#50991) 2024-08-27 17:25:01 +02:00
woocommerce-beta-tester Refactor WooCommercePayments task to use woo payment gateway from`WC()->payment_gateways->payment_gateways()` (#50953) 2024-08-28 10:44:28 +08:00
woocommerce-blocks Remove extra bottom padding in filters in the editor (#51012) 2024-08-29 10:26:11 +02:00