From 0af6a2f360a593df6f314b3fd46cd90403617449 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 git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14858 b9a71923-0436-4b27-9f14-aed3839534dd --- 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;