From d4b08daa64a34d38ec994f07762f8065988b7b7d Mon Sep 17 00:00:00 2001 From: Tamara Zuk Date: Fri, 6 Mar 2015 17:46:31 -0500 Subject: [PATCH] Avoid 'division by zero' warnings SHA 85befad283d0641b603b2ecd9efbd9a73c017f55 does not avoid these warnings if `$inc_tax` is `false`. --- includes/abstracts/abstract-wc-order.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/abstracts/abstract-wc-order.php b/includes/abstracts/abstract-wc-order.php index 246a6fb35bd..99f4190fc41 100644 --- a/includes/abstracts/abstract-wc-order.php +++ b/includes/abstracts/abstract-wc-order.php @@ -1374,7 +1374,7 @@ abstract class WC_Abstract_Order { if ( $inc_tax ) { $price = ( $item['line_subtotal'] + $item['line_subtotal_tax'] ) / max( 1, $item['qty'] ); } else { - $price = ( $item['line_subtotal'] / $item['qty'] ); + $price = ( $item['line_subtotal'] / max( 1, $item['qty'] ) ); } $price = $round ? number_format( (float) $price, 2, '.', '' ) : $price; @@ -1418,7 +1418,7 @@ abstract class WC_Abstract_Order { if ( $inc_tax ) { $price = ( $item['line_total'] + $item['line_tax'] ) / max( 1, $qty ); } else { - $price = $item['line_total'] / $qty; + $price = $item['line_total'] / max( 1, $qty ); } $price = $round ? round( $price, 2 ) : $price;