1

In my magento instance guest checkout is enabled and configuration is set as follows:

System > Config > Customer > Redirect Customer to Account Dashboard after Logging in > NO

I want to redirect user to page he is requesting. Like if user has added some products to cart without logging in and if he clicks on go to checkout button, a login popup displays. Now when he logs in, he should be redirected to checkout page. Basically he should be redirected to the page based on which button is clicked (Go to checkout or View Cart)

2
  • Check your store settings. May be you have not set it to "NO" in particular store. Check this webspeaks.in/2016/09/… May 5, 2017 at 10:25
  • I don't want to redirect user to same page. If user is on product detail page and he clicks on Go to Checkout button, after login(login in popup) he should be redirected to checkout page.
    – Sejal Shah
    May 8, 2017 at 7:00

1 Answer 1

2

You said guest checkout is enabled in your system but authentication pop up doesn't appear when you have guest checkout enabled. Go to Stores->Configuration->Sales->Checkout. Under Checkout options make sure Guest checkout is set to yes. Authentication pop up can also appear if your cart has a digital product.

Now to answer your question as to how to redirect customer where he intended to go: Overide Magento_Customer/js/view/authentication-popup.js with your theme or custom module. Line that will interest you is

if ($(loginForm).validation() &&
    $(loginForm).validation('isValid')
) {
  this.isLoading(true);
  loginAction(loginData, null, false);
}

Pass your redirect url instead of null to loginAction function. You will find implementation of loginAction in file vendor/magento/module-customer/view/frontend/web/js/action/login.js.

You can decide your redirect url based on which button was clicked. Hope that helps.

1
  • I couldn't find which file to override in 2019. Any update to this answer would help a lot!
    – F3L1X79
    Apr 10, 2019 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.