/** * Display list of product added to cart */ public function actionIndex() { // Recount // ShopModule::registerAssets(); $this->pageName = Yii::t('app', 'CART'); $this->pageTitle = $this->pageName; $this->breadcrumbs = array(Yii::t('app', 'PRODUCTION') => array('/shop'), $this->pageName); if (Yii::app()->request->isPostRequest && Yii::app()->request->getPost('recount') && !empty($_POST['quantities'])) { $this->processRecount(); } $this->form = new OrderCreateForm(); // Make order if (Yii::app()->request->isPostRequest && Yii::app()->request->getPost('create')) { if (isset($_POST['OrderCreateForm'])) { $this->form->attributes = $_POST['OrderCreateForm']; if ($this->form->validate()) { $this->form->registerGuest(); $order = $this->createOrder(); Yii::app()->cart->clear(); Yii::app()->user->setFlash('success', Yii::t('CartModule.default', 'SUCCESS_ORDER')); Yii::app()->request->redirect($this->createUrl('view', array('secret_key' => $order->secret_key))); } } } $deliveryMethods = ShopDeliveryMethod::model()->applyTranslateCriteria()->active()->orderByName()->findAll(); if (count($deliveryMethods) < 1) { throw new CHttpException(404, Yii::t('CartModule.default', 'ERROR_DELIVERY')); } $paymenyMethods = ShopPaymentMethod::model()->findAll(); if (count($paymenyMethods) < 1) { throw new CHttpException(404, Yii::t('CartModule.default', 'ERROR_PAYMENTS')); } $this->render('index', array('items' => Yii::app()->cart->getDataWithModels(), 'totalPrice' => Yii::app()->currency->convert(Yii::app()->cart->getTotalPrice()), 'deliveryMethods' => $deliveryMethods, 'paymenyMethods' => $paymenyMethods)); }
/** * Display list of product added to cart */ public function actionIndex() { // Recount if (Yii::app()->request->isPostRequest && Yii::app()->request->getPost('recount') && !empty($_POST['quantities'])) { $this->processRecount(); } $this->form = new OrderCreateForm(); // Make order if (Yii::app()->request->isPostRequest && Yii::app()->request->getPost('create')) { if (isset($_POST['OrderCreateForm'])) { $this->form->attributes = $_POST['OrderCreateForm']; if ($this->form->validate()) { $order = $this->createOrder(); Yii::app()->cart->clear(); $this->addFlashMessage(Yii::t('OrdersModule.core', 'Спасибо. Ваш заказ принят.')); Yii::app()->request->redirect($this->createUrl('view', array('secret_key' => $order->secret_key))); } } } $deliveryMethods = StoreDeliveryMethod::model()->applyTranslateCriteria()->active()->orderByName()->findAll(); $this->render('index', array('items' => Yii::app()->cart->getDataWithModels(), 'totalPrice' => Yii::app()->currency->convert(Yii::app()->cart->getTotalPrice()), 'deliveryMethods' => $deliveryMethods)); }