public function actionMyindex()
 {
     $query = Yii::$app->request->get('action');
     $id = Yii::$app->request->get('id');
     $price = Yii::$app->request->get('price');
     Yii::$app->response->format = 'json';
     $model = new Cart();
     switch ($query) {
         case "changeQuantity":
             $model->changeQuantity($_GET['id'], $_GET['val'], $_GET['price']);
             $resp = $model->getCart();
             return $resp;
             break;
         case "addToCart":
             $model->addToCart($id, $price);
             $resp = $model->getCart();
             return $resp;
             break;
         case "getCart":
             $resp = $model->getCart();
             return $resp;
             break;
         case "del":
             $model->delProduct($_GET['id']);
             $resp = $model->getCart();
             return $resp;
             break;
     }
 }
Beispiel #2
0
 public function actionAdd()
 {
     $reservationInfoId = Yii::$app->request->get('reservationInfoId');
     $qty = (int) Yii::$app->request->get('qty');
     $qty = !$qty ? 1 : $qty;
     $reservationinfo = Reservationinfo::find()->select('reservationinfo.*')->leftJoin('objreservation', 'reservationinfo.objreservation_id = objreservation.id')->where(['=', 'reservationinfo.id', $reservationInfoId])->one();
     $session = Yii::$app->session;
     $session->open();
     $card = new Cart();
     $card->addToCart($reservationinfo, $qty);
     $this->layout = false;
     return $this->render('cart-modal', compact('session'));
 }