From 3e92ec9d591112175b3a43612d3d94b7e429ebae Mon Sep 17 00:00:00 2001 From: Justin Shreve Date: Mon, 16 Jan 2017 10:57:14 -0800 Subject: [PATCH] Fix stock updating on bulk edit. --- includes/abstracts/abstract-wc-product.php | 3 ++- includes/admin/class-wc-admin-post-types.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/abstracts/abstract-wc-product.php b/includes/abstracts/abstract-wc-product.php index 45bf8e72cb1..21719df244d 100644 --- a/includes/abstracts/abstract-wc-product.php +++ b/includes/abstracts/abstract-wc-product.php @@ -1438,6 +1438,7 @@ class WC_Product extends WC_Abstract_Legacy_Product { /** * Returns whether or not the product is on sale. * + * @param string $context * @return bool */ public function is_on_sale( $context = 'view' ) { @@ -1454,7 +1455,7 @@ class WC_Product extends WC_Abstract_Legacy_Product { } else { $onsale = false; } - return 'view' === $content ? apply_filters( 'woocommerce_product_is_on_sale', $onsale, $this ) : $onsale; + return 'view' === $context ? apply_filters( 'woocommerce_product_is_on_sale', $onsale, $this ) : $onsale; } /** diff --git a/includes/admin/class-wc-admin-post-types.php b/includes/admin/class-wc-admin-post-types.php index ac34d784294..e9b75772ea1 100644 --- a/includes/admin/class-wc-admin-post-types.php +++ b/includes/admin/class-wc-admin-post-types.php @@ -1271,7 +1271,7 @@ class WC_Admin_Post_Types { $manage_stock = $was_managing_stock; } - $stock_amount = 'yes' === $manage_stock && isset( $_REQUEST['_change_stock'] ) ? wc_stock_amount( $_REQUEST['_change_stock'] ) : ''; + $stock_amount = 'yes' === $manage_stock && ! empty( $_REQUEST['change_stock'] ) ? wc_stock_amount( $_REQUEST['_stock'] ) : $product->get_stock_quantity(); if ( 'yes' === get_option( 'woocommerce_manage_stock' ) ) {