Fix non numeric warning for orders.

This commit is contained in:
Boro Sitnikovski 2017-05-03 08:31:35 +02:00
parent 6ac86952bb
commit 8f63211f1c
2 changed files with 4 additions and 4 deletions

View File

@ -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 = ( $item->get_subtotal() / max( 1, $item->get_quantity() ) );
$subtotal = ( intval( $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 = $item->get_total() / max( 1, $item->get_quantity() );
$total = intval( $item->get_total() ) / max( 1, $item->get_quantity() );
}
$total = $round ? round( $total, wc_get_price_decimals() ) : $total;

View File

@ -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', wc_format_decimal( $value ) );
$this->set_prop( 'subtotal', intval( 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', wc_format_decimal( $value ) );
$this->set_prop( 'total', intval( wc_format_decimal( $value ) ) );
// Subtotal cannot be less than total
if ( ! $this->get_subtotal() || $this->get_subtotal() < $this->get_total() ) {