Esempio n. 1
0
 /**
  * Add item to cart
  *
  * @param CartItemInterface item
  * @param int quantity
  * @return void
  */
 public function addItem(CartItemInterface $item, $quantity = 1)
 {
     if ($this->hasItem($item->getCartId())) {
         $quantity += $this->getItem($item->getCartId())->getCartQuantity();
     }
     // bound item
     if ($item instanceof BoundCartItemInterface) {
         $this->_addBinding($item->getCartId(), $item->getBoundItemCartId());
         // set quantity automatically
         if ($item->updateCartQuantityAutomatically()) {
             $quantity = $this->getItem($item->getBoundItemCartId())->getCartQuantity();
         }
     }
     $item->setCartQuantity($quantity);
     $item->setCartContext($this->_context);
     $this->_items[$item->getCartId()] = $item;
     $this->_cartModified();
 }
Esempio n. 2
0
 /**
  * Add item to cart
  *
  * @param CartItemInterface item
  * @param int quantity
  * @return void
  */
 public function addItem(CartItemInterface $item, $quantity = 1)
 {
     if (isset($this->_items[$item->getCartId()])) {
         $quantity += $this->_items[$item->getCartId()]->getCartQuantity();
     }
     $item->setCartQuantity($quantity);
     $item->setCartContext($this->_context);
     $this->_items[$item->getCartId()] = $item;
     $this->_totals = null;
 }