Stock status change. Closes #462.

This commit is contained in:
Mike Jolley 2012-01-06 17:28:33 +00:00
parent aba310f321
commit 360ca6f0af
1 changed files with 6 additions and 3 deletions

View File

@ -198,9 +198,9 @@ class woocommerce_product {
update_post_meta($this->id, '_stock', $this->stock); update_post_meta($this->id, '_stock', $this->stock);
// Out of stock attribute // 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'); 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; endif;
return $this->stock; return $this->stock;
@ -219,7 +219,10 @@ class woocommerce_product {
update_post_meta($this->id, '_stock', $this->stock); update_post_meta($this->id, '_stock', $this->stock);
// Out of stock attribute // 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; return $this->stock;
endif; endif;