'Registration for "%value%" is already in the Shopping Cart' ); function __construct(array $options) { if ($options instanceof Zend_Config) { $options = $options->toArray(); } else if (!is_array($options)) { throw new Exception('Invalid options'); } if (!array_key_exists('cartId', $options)) { throw new Exception('cartId is undefined'); } $this->setCartId($options['cartId']); } /** * @param mixed $cartId * @return $this */ public function setCartId($cartId) { $this->_cartId = $cartId; return $this; } /** * @return mixed */ public function getCartId() { return $this->_cartId; } public function isValid($value) { if ($this->isInCart($value)) { $this->_error(self::IN_CART, $value); return false; } return true; } protected function isInCart($vendorName) { return in_array($vendorName, $this->getVendorsInCart()); } public function getVendorsInCart() { $select = Qs_Db::getSelect(); $select->from(Qs_Db::getPair('CartItem', 'ci'), ['tsv.exhibitorCompanyName']); $select->joinLeft(Qs_Db::getPair('TradeShowRegistration', 'tsr'), '`ci`.`productId` = `tsr`.`id`'); $select->joinLeft(Qs_Db::getPair('TradeShowVendor', 'tsv'), '`tsv`.`registrationId` = `tsr`.`id`'); $select->where('`ci`.`cartId` = ?', $this->getCartId(), Qs_Db::INT_TYPE); $select->where('`ci`.`cartItemType` = ?', CartItemObj::ITEM_TYPE); $select->where('`tsr`.`recordType` = ?', Entity::TYPE_VENDOR); $select->where('`tsr`.`bought` = ?', 'n'); return Qs_Db::getInstance()->fetchCol($select); } }