Numeric check needs to come after formatting the decimal

This commit is contained in:
Mike Jolley 2018-02-21 14:02:44 +00:00
parent ef393b8405
commit 700246345b
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() ) {