From de52221004d27422f5c546474ed4131b9e7cf59f Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Fri, 28 Jul 2017 17:38:43 -0300 Subject: [PATCH] Fixe fatal error while trying to sum an empty array --- includes/class-wc-cart-totals.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-cart-totals.php b/includes/class-wc-cart-totals.php index 6bb186ed65c..c1bbc26b600 100644 --- a/includes/class-wc-cart-totals.php +++ b/includes/class-wc-cart-totals.php @@ -497,7 +497,7 @@ final class WC_Cart_Totals { } $this->discount_totals = $discounts->get_discounts_by_item( true ); - $this->totals['discounts_total'] = array_sum( $this->discount_totals ); + $this->totals['discounts_total'] = ! empty( $this->discount_totals ) ? array_sum( $this->discount_totals ) : 0; $this->object->coupon_discount_amounts = $discounts->get_discounts_by_coupon(); // See how much tax was 'discounted' per item and per coupon.