From 0da69c8dbeacbeb0bdd449099b7c86c05b336dc0 Mon Sep 17 00:00:00 2001 From: dMetzger Date: Mon, 21 May 2012 15:17:21 +0000 Subject: [PATCH] // Code cleaning and small fixes --- classes/Cart.php | 10 +++------- classes/CartRule.php | 8 ++++++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/classes/Cart.php b/classes/Cart.php index 10aa1d90c..9c7b5c14e 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -1459,7 +1459,7 @@ class CartCore extends ObjectModel $in_order = true; else foreach ($products as $product) - if ($cart_rule['obj']->gift_product == $product['id_product'] && $cart_rule['obj']->gift_product_attribute = $product['id_product_attribute']) + if ($cart_rule['obj']->gift_product == $product['id_product'] && $cart_rule['obj']->gift_product_attribute == $product['id_product_attribute']) $in_order = true; if ($in_order) @@ -1469,12 +1469,8 @@ class CartCore extends ObjectModel // If the cart rule offers a reduction, the amount is prorated (with the products in the package) if ($cart_rule['obj']->reduction_percent > 0 || $cart_rule['obj']->reduction_amount > 0) { - $package = null; - if (!is_null($products)) - { - $id_address_delivery = (is_null($products) ? $this->id_address_delivery : $products[0]['id_address_delivery']); - $package = array('id_address' => $id_address_delivery, 'products' => $products); - } + $id_address_delivery = (is_null($products) ? $this->id_address_delivery : $products[0]['id_address_delivery']); + $package = array('id_address' => $id_address_delivery, 'products' => $products); $order_total_discount += Tools::ps_round($cart_rule['obj']->getContextualValue($with_taxes, $virtual_context, CartRule::FILTER_ACTION_REDUCTION, $package), 2); } } diff --git a/classes/CartRule.php b/classes/CartRule.php index 462fe6bd5..7506e646f 100644 --- a/classes/CartRule.php +++ b/classes/CartRule.php @@ -882,10 +882,14 @@ class CartRuleCore extends ObjectModel if ($product['id_product'] == $this->gift_product && $product['id_product_attribute'] == $this->gift_product_attribute) { // The free gift coupon must be applied to one product only (needed for multi-shipping which manage multiple product lists) - if (!isset(CartRule::$only_one_gift[$this->id.'-'.$this->gift_product]) || CartRule::$only_one_gift[$this->id.'-'.$this->gift_product] == $id_address) + if (!isset(CartRule::$only_one_gift[$this->id.'-'.$this->gift_product]) + || CartRule::$only_one_gift[$this->id.'-'.$this->gift_product] == $id_address + || CartRule::$only_one_gift[$this->id.'-'.$this->gift_product] == 0 + || $id_address == 0) { $reduction_value += ($useTax ? $product['price_wt'] : $product['price']); - CartRule::$only_one_gift[$this->id.'-'.$this->gift_product] = $id_address; + if (!isset(CartRule::$only_one_gift[$this->id.'-'.$this->gift_product]) || CartRule::$only_one_gift[$this->id.'-'.$this->gift_product] == 0) + CartRule::$only_one_gift[$this->id.'-'.$this->gift_product] = $id_address; } } }