Apply Login Register to Checkout Process - eCart
I am following the tutorial here:
Applying Register/Login to your Checkout Process
If a user is checking out, and is NOT logged in, and they filled their cart and clicked "checkout" - they get redirected to the "login page" with a message saying that they need to be logged in to checkout. This is fine, however, the login page redirects upon successful login to the "user profile page" not back to the "cart page" that they have filled.
From a usability standpoint I would like people checking out (who are forced to login) to get redirected back to the cart, and all others logging in to redirect to the user profile page as currently setup.
Is there a way upon login for the login page to redirect depending on which scenario happens:
a. cart > checkout (must be logged in) > login page > back to cart (upon successful login)
b. login > user profile page - (for non ecommerce related logins)