Beispiel #1
0
 /**
  * Check if item is valid
  *
  * @return boolean
  */
 public function isValid()
 {
     $result = parent::isValid();
     if ($result && ($this->getProduct()->mustHaveVariants() || $this->getVariant())) {
         $variant = $this->getProduct()->getVariantByAttributeValuesIds($this->getAttributeValuesIds());
         $result = $variant && $this->getVariant() && $variant->getId() == $this->getVariant()->getId() && (!$this->product->getInventory()->getEnabled() || $this->getVariant()->getDefaultAmount() || 0 < $variant->getAmount());
     }
     return $result;
 }
Beispiel #2
0
 /**
  * Check if item is valid
  *
  * @return boolean
  */
 public function isValid()
 {
     return $this->isXpcFakeItem() || parent::isValid();
 }
Beispiel #3
0
 /**
  * Add item to order
  *
  * @param \XLite\Model\OrderItem $newItem Item to add
  *
  * @return boolean
  */
 public function addItem(\XLite\Model\OrderItem $newItem)
 {
     $result = false;
     if ($newItem->isValid() && $newItem->isConfigured()) {
         $this->addItemError = null;
         $newItem->setOrder($this);
         $item = $this->getItemByItem($newItem);
         if ($item) {
             $item->setAmount($item->getAmount() + $newItem->getAmount());
         } else {
             $this->addItems($newItem);
         }
         $result = true;
     } else {
         $this->addItemError = self::NOT_VALID_ERROR;
     }
     return $result;
 }
Beispiel #4
0
 /**
  * Check if item is valid
  *
  * @return boolean
  */
 public function isValid()
 {
     $options = array();
     if ($this->getProduct()->hasOptions()) {
         foreach ($this->getOptions() as $option) {
             $options[] = $option->getOptionId();
         }
     }
     $repository = \XLite\Core\Database::getRepo('XLite\\Module\\CDev\\ProductOptions\\Model\\OptionException');
     return parent::isValid() && (!$options || $repository->checkOptions($options));
 }
 /**
  * {@inheritDoc}
  */
 public function isValid()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'isValid', array());
     return parent::isValid();
 }