Fixed the type returned when get_stock_quantity() is empty

Since expect return an integer value, we can't return an empty string.
This can generate some kinds of errors like:

 '' >= 1 returns false
 '' >= -1 returns true

This can be a problem comparing stock quantity like we do in
WC_Product::has_enough_stock()

But using null we have:

 null >= 1 returns false
 null >= -1 returns false

cc @mikejolley

ref #9598
This commit is contained in:
Claudio Sanches 2015-11-14 15:53:36 -02:00
parent 351cdee37c
commit d931405156
1 changed files with 1 additions and 1 deletions

View File

@ -196,7 +196,7 @@ class WC_Product {
* @return int
*/
public function get_stock_quantity() {
return apply_filters( 'woocommerce_get_stock_quantity', $this->managing_stock() ? wc_stock_amount( $this->stock ) : '', $this );
return apply_filters( 'woocommerce_get_stock_quantity', $this->managing_stock() ? wc_stock_amount( $this->stock ) : null, $this );
}
/**