Пример #1
0
 public function actionView($slug)
 {
     $item = Catalog::get($slug);
     if (!$item) {
         throw new NotFoundHttpException('Item not found.');
     }
     return $this->render('view', ['item' => $item, 'addToCartForm' => new \app\models\AddToCartForm()]);
 }
Пример #2
0
 public function actionCatalog()
 {
     if (Yii::$app->request->get('slug')) {
         $item = Catalog::get(Yii::$app->request->get('slug'));
         return $this->render('catalog-item', ['item' => $item]);
     }
     $items = Catalog::items();
     return $this->render('catalog-list', ['items' => $items]);
 }
Пример #3
0
 public function actionAdd($id)
 {
     $item = Catalog::get($id);
     if (!$item) {
         throw new NotFoundHttpException('Item not found');
     }
     $form = new AddToCartForm();
     $success = 0;
     if ($form->load(Yii::$app->request->post()) && $form->validate()) {
         $response = Shopcart::add($item->id, $form->count, $form->color);
         $success = $response['result'] == 'success' ? 1 : 0;
     }
     return $this->redirect(Yii::$app->request->referrer . '?' . AddToCartForm::SUCCESS_VAR . '=' . $success);
 }
Пример #4
0
 public function actionAdd($id = null)
 {
     $id = $_POST['AddToCartForm']['id'];
     $item = Catalog::get($id);
     if (!$item) {
         throw new NotFoundHttpException('Item not found');
     }
     $form = new AddToCartForm();
     $success = 0;
     if ($form->load(Yii::$app->request->post()) && $form->validate()) {
         $response = Shopcart::add($item->id, $form->count, $form->color);
         $success = $response['result'] == 'success' ? 1 : 0;
     }
     return '<h4 class="text-success"><i class="glyphicon glyphicon-ok"></i>' . Yii::t('easyii', 'Added to cart') . '</h4>';
     //        $url = Yii::$app->request->referrer ;
     //            if (strpos($url,'?') !== false) {
     //             $url=$url.'&';
     //            }else{
     //                $url=$url.'?';
     //            }
     //            $fullurl=$url.AddToCartForm::SUCCESS_VAR.'='.$success .'&id='.$id;
     //  echo("<script>location.href = '".$fullurl."';</script>");
     // return $this->redirect($url.AddToCartForm::SUCCESS_VAR.'='.$success .'&id='.$id);
 }
Пример #5
0
 public function actionViewOnline($slug = null)
 {
     $item = Catalog::get($slug);
     if (!$item) {
         throw new NotFoundHttpException('Item not found.');
     }
     if (\Yii::$app->language == 'en') {
         $product_image = $item->image;
     } else {
         $product_image = $item->image_ar;
     }
     //og tags
     $this->view->params['metatitle'] = $item->og_title;
     $this->view->params['metaimage'] = "http://" . $_SERVER['SERVER_NAME'] . $product_image;
     $this->view->params['metadesc'] = strip_tags($item->og_desc);
     //meta tags
     $this->view->params['meta_title'] = $item->meta_title;
     $this->view->params['meta_keyword'] = strip_tags($item->meta_keyword);
     $this->view->params['meta_description'] = strip_tags($item->meta_desc);
     $cat = Catalog::cat('products');
     return $this->render('viewonline', ['item' => $item, 'addToCartForm' => new \app\models\AddToCartForm(), 'products' => $cat->items()]);
 }
Пример #6
0
 public function actionViewOnline($slug = null)
 {
     $item = Catalog::get($slug);
     if (!$item) {
         throw new NotFoundHttpException('Item not found.');
     }
     $cat = Catalog::cat('products');
     return $this->render('viewonline', ['item' => $item, 'addToCartForm' => new \app\models\AddToCartForm(), 'products' => $cat->items()]);
 }