Fix "Out of stock threshold" when filed value is empty - Fix/issue 36960 (#37855)
This commit is contained in:
commit
226af5017d
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Above notification threshold when "Out of stock threshold" filed value is empty
|
|
@ -1386,7 +1386,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
|
|||
return;
|
||||
}
|
||||
|
||||
$stock_is_above_notification_threshold = ( $this->get_stock_quantity() > get_option( 'woocommerce_notify_no_stock_amount', 0 ) );
|
||||
$stock_is_above_notification_threshold = ( (int) $this->get_stock_quantity() > absint( get_option( 'woocommerce_notify_no_stock_amount', 0 ) ) );
|
||||
$backorders_are_allowed = ( 'no' !== $this->get_backorders() );
|
||||
|
||||
if ( $stock_is_above_notification_threshold ) {
|
||||
|
|
|
@ -38,6 +38,8 @@ class OptionSanitizer {
|
|||
2
|
||||
);
|
||||
}
|
||||
// Cast "Out of stock threshold" field to absolute integer to prevent storing empty value.
|
||||
self::add_filter( 'woocommerce_admin_settings_sanitize_option_woocommerce_notify_no_stock_amount', 'absint' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -66,7 +66,7 @@ class WC_Tests_Product extends WC_Unit_Test_Case {
|
|||
* [3, 4, false, "outofstock"]
|
||||
*
|
||||
* @param int $stock_quantity Current stock quantity for the product.
|
||||
* @param bool $notify_no_stock_amount Value for the woocommerce_notify_no_stock_amount option.
|
||||
* @param int $notify_no_stock_amount Value for the woocommerce_notify_no_stock_amount option.
|
||||
* @param bool $accepts_backorders Whether the product accepts backorders or not.
|
||||
* @param string $expected_stock_status The expected stock status of the product after being saved.
|
||||
*/
|
||||
|
|
|
@ -154,7 +154,7 @@ class WC_Tests_Product_Variable extends WC_Unit_Test_Case {
|
|||
* [3, 4, false, "outofstock"]
|
||||
*
|
||||
* @param int $stock_quantity Current stock quantity for the product.
|
||||
* @param bool $notify_no_stock_amount Value for the woocommerce_notify_no_stock_amount option.
|
||||
* @param int $notify_no_stock_amount Value for the woocommerce_notify_no_stock_amount option.
|
||||
* @param bool $accepts_backorders Whether the product accepts backorders or not.
|
||||
* @param string $expected_stock_status The expected stock status of the product after being saved.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue