From 360ca6f0af2f9bb2d1c1de1435d3e2b7a043cefb Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 6 Jan 2012 17:28:33 +0000 Subject: [PATCH] Stock status change. Closes #462. --- classes/product.class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/classes/product.class.php b/classes/product.class.php index 60194af15ab..314f531cf7b 100644 --- a/classes/product.class.php +++ b/classes/product.class.php @@ -198,9 +198,9 @@ class woocommerce_product { update_post_meta($this->id, '_stock', $this->stock); // Out of stock attribute - if (!$this->is_in_stock()) : + if ($this->managing_stock() && !$this->backorders_allowed() && $this->get_total_stock()<=0) : update_post_meta($this->id, '_stock_status', 'outofstock'); - $woocommerce->clear_product_transients( $this->id ); // Clear transient + $woocommerce->clear_product_transients( $this->id ); // Clear transient endif; return $this->stock; @@ -219,7 +219,10 @@ class woocommerce_product { update_post_meta($this->id, '_stock', $this->stock); // Out of stock attribute - if ($this->is_in_stock()) update_post_meta($this->id, '_stock_status', 'instock'); + if ($this->managing_stock() && ($this->backorders_allowed() || $this->get_total_stock()>0)) : + update_post_meta($this->id, '_stock_status', 'instock'); + $woocommerce->clear_product_transients( $this->id ); // Clear transient + endif; return $this->stock; endif;