Merge pull request #11324 from woothemes/out-of-stock-threshold-11322

Out of stock threshold 11322
This commit is contained in:
Mike Jolley 2016-07-20 14:44:41 +02:00 committed by GitHub
commit bc80b75540
3 changed files with 8 additions and 32 deletions

View File

@ -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', $this );
}
/**

View File

@ -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(

View File

@ -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 );
}
/**