intval -> floatval

This commit is contained in:
Boro Sitnikovski 2017-05-04 10:09:16 +02:00
parent 8f63211f1c
commit f493afe718
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 = ( 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;

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', 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() ) {