Example #1
0
 /**
  * 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->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->onUpdatePoistion(new CEvent($this));
     $this->saveState();
 }
 /**
  * Updates the position in the shopping cart
  * If the position was previously added, then it will be updated in shopping cart,
  * if the position was not previously in the cart, it will be added there.
  * If the count of less than 1, the position will be deleted.
  *
  * @param IECartPosition $position
  * @param int $quantity
  */
 public function updateStored(IECartPosition $position, $quantity)
 {
     if ($this->objSectorCiudad !== null) {
         $key = $position->getId();
         $position->generate(array('objSectorCiudad' => $this->objSectorCiudad, 'codigoPerfil' => $this->codigoPerfil));
         $position->setQuantityStored($quantity);
         if ($position->getQuantity(true) + $position->getQuantity(false) < 1) {
             $this->remove($key);
         } else {
             parent::add($key, $position);
         }
         $this->applyDiscounts();
         $this->onUpdatePoistion(new CEvent($this));
         $this->saveState();
         return true;
     }
     return false;
 }
Example #3
0
 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();
 }
Example #4
0
 /**
  * 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));
 }