EShoppingCart::update PHP Method

update() public method

If count is less than 1, the position will be deleted.
public update ( IECartPosition $position, integer $quantity )
$position IECartPosition
$quantity integer
    public function update(IECartPosition $position, $quantity)
    {
        $key = $position->getId();
        $position->detachBehavior("CartPosition");
        $position->attachBehavior("CartPosition", new ECartPositionBehaviour());
        $position->setRefresh($this->refresh);
        $position->setQuantity($quantity);
        if ($position->getQuantity() < 1) {
            $this->remove($key);
        } else {
            parent::add($key, $position);
        }
        $this->applyDiscounts();
        $this->saveState();
        $this->eventManager->fire(CartEvents::CART_UPDATE, new CartEvent(Yii::app()->getUser(), $this));
    }