コード例 #1
0
ファイル: EShoppingCart.php プロジェクト: bgshechka/pos-shop
 public function updateCount(IECartPosition $position, $count)
 {
     if (!$position instanceof CComponent) {
         throw new InvalidArgumentException('invalid argument 1, product must implement CComponent interface');
     }
     $key = $position->getId();
     $position->detachBehavior("CartPosition");
     $position->attachBehavior("CartPosition", new ECartPositionBehaviour());
     $position->setRefresh($this->refresh);
     $position->count = $count;
     $position->calculatePriceForThisCount();
     parent::add($key, $position);
     $this->applyDiscounts();
     $this->onUpdatePosition(new CEvent($this));
     $this->saveState();
 }
コード例 #2
0
ファイル: EShoppingCart.php プロジェクト: elbrusto/YiiShop
 /**
  * Updates the position in the shopping cart
  * If position was previously added, then it will be updated in shopping cart,
  * if position was not previously in the cart, it will be added there.
  * If count is less than 1, the position will be deleted.
  *
  * @param IECartPosition $position
  * @param int $quantity
  */
 public function update(IECartPosition $position, $quantity)
 {
     if (!$position instanceof CComponent) {
         throw new InvalidArgumentException('invalid argument 1, product must implement CComponent interface');
     }
     $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->onUpdatePosition(new CEvent($this));
     $this->saveState();
 }
コード例 #3
0
ファイル: EShoppingCart.php プロジェクト: yupe/yupe
 /**
  * Updates the position in the shopping cart
  * If position was previously added, then it will be updated in shopping cart,
  * if position was not previously in the cart, it will be added there.
  * If count is less than 1, the position will be deleted.
  *
  * @param IECartPosition $position
  * @param int $quantity
  */
 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));
 }