/**
  * Show message about wrong product amount
  *
  * @param \XLite\Model\OrderItem $item Order item
  *
  * @return void
  */
 protected function processInvalidAmountError(\XLite\Model\OrderItem $item)
 {
     \XLite\Core\TopMessage::addWarning('You tried to buy more items of "{{product}}" product {{description}} than are in stock. We have {{amount}} item(s) only. Please adjust the product quantity.', array('product' => $item->getProduct()->getName(), 'description' => $item->getExtendedDescription(), 'amount' => $item->getProductAvailableAmount()));
 }
Beispiel #2
0
 /**
  * Return false if order item amount exceeds maximum allowed value
  *
  * @param \XLite\Model\OrderItem $entity Order item entity
  *
  * @return boolean
  */
 protected function isItemHasWrongAmount($entity)
 {
     $oldAmount = $this->orderItemsData[$entity->getItemId()]['amount'];
     $maxAmount = $entity->getProductAvailableAmount();
     return $oldAmount + $maxAmount < $entity->getAmount();
 }
Beispiel #3
0
 /**
  * Get available amount for the product
  *
  * @return integer
  */
 public function getProductAvailableAmount()
 {
     return $this->getVariant() && !$this->getVariant()->getDefaultAmount() ? $this->getVariant()->getAvailableAmount() : parent::getProductAvailableAmount();
 }
Beispiel #4
0
 /**
  * Assemble recalculate item event
  *
  * @param \XLite\Model\OrderItem $item Order item
  *
  * @return array
  */
 protected function assembleRecalculateItemEvent(\XLite\Model\OrderItem $item)
 {
     $maxAmount = $item->getProductAvailableAmount();
     if ($item->isPersistent() && \XLite\Core\Request::getInstance()->oldAmount) {
         $maxAmount += \XLite\Core\Request::getInstance()->oldAmount;
         \XLite\Core\Request::getInstance()->oldAmount = null;
     }
     return array('item_id' => $item->getItemId(), 'requestId' => \XLite\Core\Request::getInstance()->requestId, 'price' => $item->getNetPrice(), 'max_qty' => $maxAmount);
 }
 /**
  * {@inheritDoc}
  */
 public function getProductAvailableAmount()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getProductAvailableAmount', array());
     return parent::getProductAvailableAmount();
 }