Cast order totals as floats when calculating net total (https://github.com/woocommerce/woocommerce-admin/pull/1945)

This commit is contained in:
Joshua T Flowers 2019-04-02 13:43:12 +08:00 committed by GitHub
parent 17ef1fc9c6
commit b03362da68
1 changed files with 2 additions and 2 deletions

View File

@ -504,11 +504,11 @@ class WC_Admin_Reports_Orders_Stats_Data_Store extends WC_Admin_Reports_Data_Sto
* @return float
*/
protected static function get_net_total( $order ) {
$net_total = $order->get_total() - $order->get_total_tax() - $order->get_shipping_total();
$net_total = floatval( $order->get_total() ) - floatval( $order->get_total_tax() ) - floatval( $order->get_shipping_total() );
$refunds = $order->get_refunds();
foreach ( $refunds as $refund ) {
$net_total += $refund->get_total() - $refund->get_total_tax() - $refund->get_shipping_total();
$net_total += floatval( $refund->get_total() ) - floatval( $refund->get_total_tax() ) - floatval( $refund->get_shipping_total() );
}
return $net_total > 0 ? (float) $net_total : 0;