/** * checkout view * @author cangzhou.wu(wucangzhou@gmail.com) * @return string * @throws \yii\web\NotFoundHttpException */ public function actionCheckout() { $star_id = (int) Yii::$app->request->get('star_id'); $shoppingCart = new ShoppingCart(); $cartItems = $shoppingCart->cartItems; if ($star_id) { $cartItems = $shoppingCart->serialCartItems(); if (isset($cartItems[$star_id])) { $cartItems = $cartItems[$star_id]; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } return $this->render('index', ['cartItems' => $cartItems]); }
public function actionIndex() { $shoppingCartModel = new ShoppingCart(); $cartItems = $shoppingCartModel->serialCartItems(); return $this->render('index', ['cartItems' => $cartItems, 'shoppingCartModel' => $shoppingCartModel]); }