From b8d97dbb02e26201dad46172c6bbe9e4d6e6785f Mon Sep 17 00:00:00 2001 From: dMetzger Date: Tue, 24 Apr 2012 17:10:32 +0000 Subject: [PATCH] [-] FO : cart rules are now removed when the cart is empty #PSTEST-1205 --- classes/Cart.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/classes/Cart.php b/classes/Cart.php index 411970470..359f2e96a 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -1159,8 +1159,13 @@ class CartCore extends ObjectModel { // refresh cache of self::_products $this->_products = $this->getProducts(true); - /* Update cart */ - return $this->update(true); + $return = $this->update(true); + + // If there isn't any product left, remove all the cart rules associated + if (!$this->nbProducts()) + $result = Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'cart_cart_rule` WHERE `id_cart` = '.(int)$this->id); + + return $return; } return false;