EShoppingCart::put PHP Method

put() public method

Add item to the shopping cart If the position was previously added to the cart, then information about it is updated, and count increases by $quantity
public put ( IECartPosition $position, $quantity = 1 )
$position IECartPosition
    public function put(IECartPosition $position, $quantity = 1)
    {
        $key = $position->getId();
        if ($this->itemAt($key) instanceof IECartPosition) {
            $position = $this->itemAt($key);
            $oldQuantity = $position->getQuantity();
            $quantity += $oldQuantity;
        }
        $this->update($position, $quantity);
        $this->eventManager->fire(CartEvents::CART_ADD_ITEM, new CartEvent(Yii::app()->getUser(), $this));
    }

Usage Example

Esempio n. 1
0
 function testEmpty()
 {
     $this->setUp();
     $cart = new EShoppingCart();
     $this->assertTrue($cart->isEmpty());
     $book = Book::model()->findByPk(1);
     $cart->put($book);
     $this->assertFalse($cart->isEmpty());
 }
All Usage Examples Of EShoppingCart::put