Esempio 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;
 }
Esempio n. 2
0
 /**
  * Return "locked" amount: items already added to the cart
  *
  * @return integer
  */
 public function getLockedAmount()
 {
     return \Includes\Utils\ArrayManager::sumObjectsArrayFieldValues($this->getLockedItems(), 'getAmount', true);
 }
Esempio n. 3
0
 /**
  * Check if there is enough disk free space.
  * Return message on error
  *
  * @return string
  */
 protected function checkDiskFreeSpace()
 {
     $message = null;
     $totalSize = \Includes\Utils\ArrayManager::sumObjectsArrayFieldValues($this->getEntries(), 'getPackSize');
     $freeSpaceRaw = \Includes\Utils\FileManager::getDiskFreeSpace(LC_DIR_TMP);
     $freeSpace = null !== $freeSpaceRaw ? max(0, $freeSpaceRaw - self::FREE_SPACE_RESERVE) : null;
     if (null !== $freeSpace && $totalSize > $freeSpace) {
         $message = \XLite\Core\Translation::getInstance()->translate('Not enough disk space. Required: {{req}} (+{{reserve}} reserve). Available: {{avail}}', array('req' => \XLite\Core\Converter::formatFileSize($totalSize), 'reserve' => \XLite\Core\Converter::formatFileSize(self::FREE_SPACE_RESERVE), 'avail' => \XLite\Core\Converter::formatFileSize($freeSpace)));
     }
     return $message;
 }