From cb4cad127c7f94a3033affd498db0b8aa4529082 Mon Sep 17 00:00:00 2001 From: darrylcoder Date: Wed, 25 Feb 2015 09:02:13 -0800 Subject: [PATCH] fixed bug for conditions became empty --- src/Darryldecode/Cart/Cart.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Darryldecode/Cart/Cart.php b/src/Darryldecode/Cart/Cart.php index a4acc6f..d7dd351 100644 --- a/src/Darryldecode/Cart/Cart.php +++ b/src/Darryldecode/Cart/Cart.php @@ -9,13 +9,6 @@ class Cart { - /** - * the cart conditions - * - * @var CartConditionCollection - */ - protected $conditions; - /** * the item storage * @@ -66,7 +59,6 @@ public function __construct($session, $events, $instanceName, $session_key) $this->instanceName = $instanceName; $this->sessionKeyCartItems = $session_key.'_cart_items'; $this->sessionKeyCartConditions = $session_key.'_cart_conditions'; - $this->conditions = new CartConditionCollection(); $this->events->fire($this->getInstanceName().'.created', array($this)); } @@ -255,9 +247,11 @@ public function condition($condition) if( ! $condition instanceof CartCondition ) throw new InvalidConditionException('Argument 1 must be an instance of \'Darryldecode\Cart\CartCondition\''); - $this->conditions->put($condition->getName(), $condition); + $conditions = $this->getConditions(); + + $conditions->put($condition->getName(), $condition); - $this->saveConditions($this->conditions); + $this->saveConditions($conditions); return $this; }