Ejemplo n.º 1
0
 /**
  * Return minimum quantity
  *
  * @return integer
  */
 protected function getMinQuantity()
 {
     $minQuantity = $this->getProduct()->getMinQuantity($this->getCart()->getProfile() ? $this->getCart()->getProfile()->getMembership() : null);
     $result = parent::getMinQuantity();
     $minimumQuantity = $minQuantity ? $minQuantity : $result;
     if (!$this->isCartPage()) {
         $items = \XLite\Model\Cart::getInstance()->getItemsByProductId($this->getProduct()->getProductId());
         $quantityInCart = $items ? \Includes\Utils\ArrayManager::sumObjectsArrayFieldValues($items, 'getAmount', true) : 0;
         $result = $minimumQuantity > $quantityInCart ? $minimumQuantity - $quantityInCart : $result;
     } else {
         $result = $minimumQuantity;
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * Return maximum allowed quantity
  *
  * @return integer
  */
 protected function getMaxQuantity()
 {
     return $this->getOrderItem() && $this->getOrderItem()->getVariant() && !$this->getOrderItem()->getVariant()->getDefaultAmount() ? $this->getOrderItem()->getVariant()->getAvailableAmount() + $this->getOrderItem()->getAmount() : parent::getMaxQuantity();
 }