From 6422669c95f23df4ca73cfa32bc5538648b23693 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 1 Jul 2016 11:59:52 +0100 Subject: [PATCH 1/3] Base is_in_stock purely on stock status and not stock levels --- includes/abstracts/abstract-wc-product.php | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/includes/abstracts/abstract-wc-product.php b/includes/abstracts/abstract-wc-product.php index 80b931edd63..363308511d4 100644 --- a/includes/abstracts/abstract-wc-product.php +++ b/includes/abstracts/abstract-wc-product.php @@ -608,20 +608,7 @@ class WC_Product { * @return bool */ public function is_in_stock() { - $status = $this->stock_status === 'instock'; - - /** - * Sanity check to ensure stock qty is not lower than 0 but still listed - * instock. - * - * Check is not required for products on backorder since they can be - * instock regardless of actual stock quantity. - */ - if ( $this->managing_stock() && ! $this->backorders_allowed() && $this->get_total_stock() <= get_option( 'woocommerce_notify_no_stock_amount' ) ) { - $status = false; - } - - return apply_filters( 'woocommerce_product_is_in_stock', $status ); + return apply_filters( 'woocommerce_product_is_in_stock', $this->stock_status === 'instock' ); } /** From c495552301c5ebd3c6400a65aa166ee4f9e4cc11 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 1 Jul 2016 12:01:37 +0100 Subject: [PATCH 2/3] Same for variations --- includes/abstracts/abstract-wc-product.php | 2 +- includes/class-wc-product-variation.php | 15 +-------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/includes/abstracts/abstract-wc-product.php b/includes/abstracts/abstract-wc-product.php index 363308511d4..2f2a478f324 100644 --- a/includes/abstracts/abstract-wc-product.php +++ b/includes/abstracts/abstract-wc-product.php @@ -608,7 +608,7 @@ class WC_Product { * @return bool */ public function is_in_stock() { - return apply_filters( 'woocommerce_product_is_in_stock', $this->stock_status === 'instock' ); + return apply_filters( 'woocommerce_product_is_in_stock', $this->stock_status === 'instock', $this ); } /** diff --git a/includes/class-wc-product-variation.php b/includes/class-wc-product-variation.php index 9100100bd41..50fe2d43969 100644 --- a/includes/class-wc-product-variation.php +++ b/includes/class-wc-product-variation.php @@ -423,20 +423,7 @@ class WC_Product_Variation extends WC_Product { * @return bool */ public function is_in_stock() { - $status = $this->stock_status === 'instock'; - - /** - * Sanity check to ensure stock qty is not lower than 0 but still listed - * instock. - * - * Check is not required for products on backorder since they can be - * instock regardless of actual stock quantity. - */ - if ( true === $this->managing_stock() && ! $this->backorders_allowed() && $this->get_stock_quantity() <= get_option( 'woocommerce_notify_no_stock_amount' ) ) { - $status = false; - } - - return apply_filters( 'woocommerce_variation_is_in_stock', $status ); + return apply_filters( 'woocommerce_variation_is_in_stock', $this->stock_status === 'instock', $this ); } /** From 99e1e215bb680459a48abd741b231cc1d00ba2e2 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 1 Jul 2016 12:06:31 +0100 Subject: [PATCH 3/3] Tooltips --- includes/admin/settings/class-wc-settings-products.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/includes/admin/settings/class-wc-settings-products.php b/includes/admin/settings/class-wc-settings-products.php index e9ca0c3aeef..64adb768982 100644 --- a/includes/admin/settings/class-wc-settings-products.php +++ b/includes/admin/settings/class-wc-settings-products.php @@ -301,7 +301,7 @@ class WC_Settings_Products extends WC_Settings_Page { array( 'title' => __( 'Low Stock Threshold', 'woocommerce' ), - 'desc' => '', + 'desc' => __( 'When product stock reaches this amount you will be notified via email.', 'woocommerce' ), 'id' => 'woocommerce_notify_low_stock_amount', 'css' => 'width:50px;', 'type' => 'number', @@ -310,12 +310,13 @@ class WC_Settings_Products extends WC_Settings_Page { 'step' => 1 ), 'default' => '2', - 'autoload' => false + 'autoload' => false, + 'desc_tip' => true, ), array( 'title' => __( 'Out Of Stock Threshold', 'woocommerce' ), - 'desc' => '', + 'desc' => __( 'When product stock reaches this amount the stock status will change to "out of stock" and you will be notified via email. This setting does not affect existing "in stock" products.', 'woocommerce' ), 'id' => 'woocommerce_notify_no_stock_amount', 'css' => 'width:50px;', 'type' => 'number', @@ -323,7 +324,8 @@ class WC_Settings_Products extends WC_Settings_Page { 'min' => 0, 'step' => 1 ), - 'default' => '0' + 'default' => '0', + 'desc_tip' => true, ), array(