Пример #1
0
 /**
  * @return string|\yii\web\Response
  */
 public function actionProfile()
 {
     $model = User::findIdentity(\Yii::$app->user->identity->getId());
     if ($model->load(\Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['details']);
     }
     return $this->render('profile', ['model' => $model, 'countries' => Shop::countries()]);
 }
Пример #2
0
 /**
  * @return string
  */
 public function actionAddress()
 {
     $cart = Cart::get();
     if (!$cart->lines) {
         return $this->redirect(['/checkout/cart/index']);
     }
     $address = new OrderAddress();
     if (!\Yii::$app->user->isGuest) {
         /** @var User $identity */
         $identity = \Yii::$app->user->identity;
         $address->setAttributes($identity->attributes);
     }
     if ($address->load(\Yii::$app->request->post()) && $address->validate()) {
         $address->save();
         $this->redirect(['place']);
     }
     return $this->render('address', ['address' => $address, 'countries' => Shop::countries(), 'page' => Shop::page(Pages::CHECKOUT)]);
 }