Reputation: 2790
here is my code, I am missing something obvious, but not able to figure out:
public function actionCheckout()
{
$model = new User;
// $userProfile = UserProfile::find(['user_id'=>$model->id])->One();
$userProfile = new UserProfile;
$cartItems = $this->cart->getItems();
if (Yii::$app->request->post()) {
$cart = (array_merge(...$_SESSION['primary-cart']));
if($_POST['account-option']=="on"){
// echo "true";exit;
$userProfile->first_name = $_POST['User']['first_name'];
$userProfile->last_name = $_POST['User']['last_name'];
$userProfile->phone = $_POST['User']['phone'];
$userProfile->email = $_POST['User']['email'];
$userProfile->address1 = $_POST['UserProfile']['address1'];
// $userProfile->address2 = $_POST['UserProfile']['address2'];
$userProfile->city = $_POST['UserProfile']['city'];
$userProfile->state = $_POST['UserProfile']['state'];
$userProfile->Country = $_POST['User']['Country'];
$userProfile->pincode = $_POST['UserProfile']['pincode'];
$userProfile->save();
}
$params=[
'id'=>$cart['productId'],
'amount'=> $cart['price'],
'productinfo' => $cart['title'],
'firstname' => $_POST['User']['first_name'],
'email' => $_POST['User']['email'],
'phone' => $_POST['User']['phone']
];
Yii::$app->Payu->PayuCheckout($params);
}
return $this->render('checkout',['model'=>$model,'userProfile' =>$userProfile,'cartItems' => $cartItems]);
}
I am getting redirected to payU correctly, without any issue, but data is not saved to userProfile also nothing in the log as well.
Upvotes: 0
Views: 39
Reputation: 492
Try
var_dump($userProfile->getErrors())
right after saving it to see if there are any errors related to the model fields.
Upvotes: 1