diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php index 059bdc92b..f59b632a2 100755 --- a/core/lib/Thelia/Action/Cart.php +++ b/core/lib/Thelia/Action/Cart.php @@ -110,7 +110,7 @@ class Cart extends BaseAction implements EventSubscriberInterface ->filterByCartId($cart->getId()) ->filterById($cartItemId) ->findOne(); - + if ($cartItem) { $this->updateQuantity($cartItem, $quantity); } @@ -155,7 +155,7 @@ class Cart extends BaseAction implements EventSubscriberInterface protected function updateQuantity(CartItem $cartItem, $quantity) { $cartItem->setDisptacher($this->getDispatcher()); - $cartItem->addQuantity($quantity) + $cartItem->updateQuantity($quantity) ->save(); } diff --git a/core/lib/Thelia/Model/CartItem.php b/core/lib/Thelia/Model/CartItem.php index e82d266ea..39408763e 100644 --- a/core/lib/Thelia/Model/CartItem.php +++ b/core/lib/Thelia/Model/CartItem.php @@ -41,27 +41,25 @@ class CartItem extends BaseCartItem * @param $value * @return $this */ - public function addQuantity($value) + public function updateQuantity($value) { $currentQuantity = $this->getQuantity(); - $newQuantity = $currentQuantity + $value; - - if($newQuantity <= 0) + if($value <= 0) { - $newQuantity = $currentQuantity; + $value = $currentQuantity; } if(ConfigQuery::read("verifyStock", 1) == 1) { $productSaleElements = $this->getProductSaleElements(); - if($productSaleElements->getQuantity() < $newQuantity) { - $newQuantity = $currentQuantity; + if($productSaleElements->getQuantity() < $value) { + $value = $currentQuantity; } } - $this->setQuantity($newQuantity); + $this->setQuantity($value); return $this; }