Example #1
0
 /**
  *
  * Modify article's quantity
  *
  * don't use Form here just test the Request.
  *
  * @param \Thelia\Core\Event\Cart\CartEvent $event
  */
 public function changeItem(CartEvent $event)
 {
     if (null !== ($cartItemId = $event->getCartItemId()) && null !== ($quantity = $event->getQuantity())) {
         $cart = $event->getCart();
         $cartItem = CartItemQuery::create()->filterByCartId($cart->getId())->filterById($cartItemId)->findOne();
         if ($cartItem) {
             $event->setCartItem($this->updateQuantity($event->getDispatcher(), $cartItem, $quantity));
         }
     }
 }