From 700246345b72eab0b9024492bd9032d295cc96d3 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Wed, 21 Feb 2018 14:02:44 +0000 Subject: [PATCH] Numeric check needs to come after formatting the decimal --- includes/class-wc-order-item-product.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/includes/class-wc-order-item-product.php b/includes/class-wc-order-item-product.php index e52779327e4..ce8a5834f22 100644 --- a/includes/class-wc-order-item-product.php +++ b/includes/class-wc-order-item-product.php @@ -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() ) {