Merge pull request #19069 from woocommerce/fix/19064

Numeric check needs to come after formatting the decimal
This commit is contained in:
Mike Jolley 2018-02-21 15:08:30 +00:00 committed by GitHub
commit e614c9ce22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -96,11 +96,13 @@ class WC_Order_Item_Product extends WC_Order_Item {
* @throws WC_Data_Exception
*/
public function set_subtotal( $value ) {
$value = wc_format_decimal( $value );
if ( ! is_numeric( $value ) ) {
$value = 0;
}
$this->set_prop( 'subtotal', wc_format_decimal( $value ) );
$this->set_prop( 'subtotal', $value );
}
/**
@ -110,11 +112,13 @@ class WC_Order_Item_Product extends WC_Order_Item {
* @throws WC_Data_Exception
*/
public function set_total( $value ) {
$value = wc_format_decimal( $value );
if ( ! is_numeric( $value ) ) {
$value = 0;
}
$this->set_prop( 'total', wc_format_decimal( $value ) );
$this->set_prop( 'total', $value );
// Subtotal cannot be less than total
if ( '' === $this->get_subtotal() || $this->get_subtotal() < $this->get_total() ) {