'Can not determine item price', self::ERROR_VALIDATE_CART_ITEM_PRICE_NOT_FLOAT => 'Item price is wrong', self::ERROR_VALIDATE_CART_ITEM_COUNT => 'Items count is wrong', self::ERROR_VALIDATE_CART_ITEM_ADD => 'Error add product to the cart', self::ERROR_MULTI_VALIDATE_CART_ITEM_ADD => 'Errors add product to the cart:
%s', self::ERROR_ITEM_REMOVE => 'Item has not exists' ); /** * Messages map * * @var array */ protected static $_messageMap = array( self::MESSAGE_ITEM_HAS_ADDED => 'Product has been added to the Shopping Cart', self::MESSAGE_ITEM_HAS_UPDATED => 'Product quantity has been updated', self::MESSAGE_ITEM_HAS_REMOVED => 'Product has been removed from the Shopping Cart' ); /** @var Qs_ViewController_List */ protected $_list; public static function getError($error) { return self::$_errorMap[$error]; } public static function getMessage($message) { return self::$_messageMap[$message]; } /** * Return items count * * @return int */ public function getItemsCount() { return $this->_getDataObj()->getItemsCount(); } /** * Remove item * * @return App_ECommerce_Cart_Abstract_View */ protected function _doRemoveItem() { /** @var Exception $e */ if (($e = $this->_getDataObj()->removeItem(Qs_Request::getGetValue('itemId'))) instanceof Exception) { if ($e instanceof Qs_Db_Obj_Exception) { $this->_setBackError($e->getMessage()); } else { Qs_Debug::processException($e); } } elseif ($e == 0) { $this->_setBackError(self::getError(self::ERROR_ITEM_REMOVE)); } else { $this->_setBackMessage(self::getMessage(self::MESSAGE_ITEM_HAS_REMOVED)); $this->_log(); } $this->_doBack(); return $this; } public function setList(Qs_ViewController_List $list) { $this->_list = $list; return $this; } public function setPreviewMode($previewMode = true) { $this->_previewMode = $previewMode; return $this; } public function getPreviewMode() { return $this->_previewMode; } public function _getLog() { if (null === $this->_log) { parent::_getLog(); $this->_log->setAction('list', 'Viewed Shopping Cart'); $this->_log->setAction('addItem', 'Added "%itemTitle%" Product to the Shopping Cart'); $this->_log->setAction('updateItem', 'Updated "%itemTitle%" Product in the Shopping Cart'); $this->_log->setAction('removeItem', 'Removed "%itemTitle%" Product from the Shopping Cart'); } return $this->_log; } }