public function actionOrder($id) { $this->layout = 'page'; $model = new Order(); $categories = Category::findAll(['status' => Category::STATUS_ENABLED]); $product = Product::find()->where(['id' => $id, 'status' => Product::STATUS_ENABLED])->limit(1)->one(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { $order = new Order(); $order->key = strtoupper(Yii::$app->security->generateRandomString(6)); $order->name = $product->name; $order->thumbnail = $product->thumbnail; $order->price = $product->price; $order->count = $model->count; $order->email = $model->email; $order->message = $model->message; $order->date = time(); $order->insert(); Yii::$app->session->set('orderID', $order->id); return $this->redirect(['product/confirm']); } else { return $this->render('order', ['model' => $model, 'categories' => $categories, 'product' => $product]); } }