From 900c10120de81bb2971ff88e23d9dd01b710397b Mon Sep 17 00:00:00 2001 From: dMetzger Date: Mon, 11 Jun 2012 14:36:16 +0000 Subject: [PATCH] [-] FO : potential divide by zero removed #PSCFV-2787 --- classes/CartRule.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/classes/CartRule.php b/classes/CartRule.php index 8bc7361e3..d6625e25e 100644 --- a/classes/CartRule.php +++ b/classes/CartRule.php @@ -799,8 +799,12 @@ class CartRuleCore extends ObjectModel if ($this->reduction_amount) { $prorata = 1; - if (!is_null($package)) - $prorata = $context->cart->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS, $package['products']) / $context->cart->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS); + if (!is_null($package) && count($all_products)) + { + $total_products = $context->cart->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS); + if ($total_products) + $prorata = $context->cart->getOrderTotal($use_tax, Cart::ONLY_PRODUCTS, $package['products']) / $total_products; + } $reduction_amount = $this->reduction_amount; // If we need to convert the voucher value to the cart currency