diff --git a/includes/abstracts/abstract-wc-order.php b/includes/abstracts/abstract-wc-order.php index 53a48940f04..1ea430096cf 100644 --- a/includes/abstracts/abstract-wc-order.php +++ b/includes/abstracts/abstract-wc-order.php @@ -1194,7 +1194,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order { if ( $inc_tax ) { $subtotal = ( $item->get_subtotal() + $item->get_subtotal_tax() ) / max( 1, $item->get_quantity() ); } else { - $subtotal = ( intval( $item->get_subtotal() ) / max( 1, $item->get_quantity() ) ); + $subtotal = ( floatval( $item->get_subtotal() ) / max( 1, $item->get_quantity() ) ); } $subtotal = $round ? number_format( (float) $subtotal, wc_get_price_decimals(), '.', '' ) : $subtotal; @@ -1242,7 +1242,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order { if ( $inc_tax ) { $total = ( $item->get_total() + $item->get_total_tax() ) / max( 1, $item->get_quantity() ); } else { - $total = intval( $item->get_total() ) / max( 1, $item->get_quantity() ); + $total = floatval( $item->get_total() ) / max( 1, $item->get_quantity() ); } $total = $round ? round( $total, wc_get_price_decimals() ) : $total; diff --git a/includes/class-wc-order-item-product.php b/includes/class-wc-order-item-product.php index c6a4346f0e6..dc587755a0f 100644 --- a/includes/class-wc-order-item-product.php +++ b/includes/class-wc-order-item-product.php @@ -96,7 +96,7 @@ class WC_Order_Item_Product extends WC_Order_Item { * @throws WC_Data_Exception */ public function set_subtotal( $value ) { - $this->set_prop( 'subtotal', intval( wc_format_decimal( $value ) ) ); + $this->set_prop( 'subtotal', floatval( wc_format_decimal( $value ) ) ); } /** @@ -106,7 +106,7 @@ class WC_Order_Item_Product extends WC_Order_Item { * @throws WC_Data_Exception */ public function set_total( $value ) { - $this->set_prop( 'total', intval( wc_format_decimal( $value ) ) ); + $this->set_prop( 'total', floatval( wc_format_decimal( $value ) ) ); // Subtotal cannot be less than total if ( ! $this->get_subtotal() || $this->get_subtotal() < $this->get_total() ) {