woocommerce/includes/abstracts
Nestor Soriano 9aa3c54bd9 Fix variable product stock status not being properly set on save
When a product is saved its validate_props method is invoked,
and this recalculates the stock_status property based on whether
the product manages stock or not, the stock quantity, and the
value of the woocommerce_notify_no_stock_amount option.

In the case of variable products, and when stock is managed, the stock
was set to "instock" when the current stock was enough, but only
if the "stock_quantity" property was in the list of changed properties
for the object (the method in the base product class doen't check
for changed properties). This is a problem because the
wc_update_product_stock function updates stock_quantity but via direct
database modification, and thus stock_quantity isn't considered
modified. Therefore stock modifications via wc_update_product_stock
don't update stock_status on the product (e.g. when going from 0 to 1
after a refund the stock status will remain as "outofstock").

The fix consists of removing the check for changed properties since
it's not done anyway in the other cases (when stock is below the
woocommerce_notify_no_stock_amount threshold) nor in the base class.

Also, validate_props is refactored for readabiliyy, and an useless
set_stock_status() call placed right before save()
in wc_update_product_stock is removed.
2020-06-29 14:32:17 +02:00
..
abstract-wc-data.php Merge pull request #24066 from malviyaritesh/fix/24062 2020-01-23 14:59:39 +01:00
abstract-wc-deprecated-hooks.php Replaced direct access of many constants with the Constants library 2020-01-31 22:18:47 -08:00
abstract-wc-integration.php Fix Generic.Formatting.MultipleStatementAlignment violations 2019-12-20 14:21:08 -03:00
abstract-wc-log-handler.php Fix PEAR.Functions.FunctionCallSignature violations 2019-12-20 15:25:23 -03:00
abstract-wc-object-query.php PHPCS passing for abstract-wc-object-query.php 2018-03-05 13:39:05 +02:00
abstract-wc-order.php Use common code and round in subtotal. 2020-05-27 23:48:47 +05:30
abstract-wc-payment-gateway.php Changed all of the constant accesses into corresponding Automattic\Jetpack\Constants usages 2020-01-28 21:21:29 -08:00
abstract-wc-payment-token.php PHPCS passing for abstract-wc-payment-token.php 2018-03-05 13:54:54 +02:00
abstract-wc-privacy.php Fix Generic.Formatting.MultipleStatementAlignment violations 2019-12-20 14:21:08 -03:00
abstract-wc-product.php Fix variable product stock status not being properly set on save 2020-06-29 14:32:17 +02:00
abstract-wc-session.php PHPCS passing for abstract-wc-session.php 2018-03-05 15:00:52 +02:00
abstract-wc-settings-api.php Update min files and selectWoo 2020-06-16 17:15:12 +02:00
abstract-wc-shipping-method.php Fix WordPress.Arrays.MultipleStatementAlignment errors automatically using phpcbf 2019-12-20 13:51:26 -03:00
abstract-wc-widget.php Changed all of the constant accesses into corresponding Automattic\Jetpack\Constants usages 2020-01-28 21:21:29 -08:00
class-wc-background-process.php Fix some memory limit values not correctly converting to bytes 2018-10-15 01:26:45 -05:00