Jump to content

Redirect customer to the previous page (after login)


Recommended Posts

The function Tools::redirect(), which serves as a certain wrapper for the construction header(‘Location:’.$url); , is specifically responsible for the redirect. In this function it is used 7 times.

 

// redirection: if cart is not empty : redirection to the cart
if (count($this->context->cart->getProducts(true)) > 0)
    Tools::redirect('index.php?controller=order&multi-shipping='.(int)Tools::getValue('multi-shipping')); //I advise not to change address here,  because if a customer has any items in the cart Prestashop will redirect him to the checkout page. And if this will be some other page the customer can get upset.
	 // else : redirection to the account
else
    Tools::redirect('index.php?controller=my-account'); //here you can put the page which seems the most obvious to you.
…..
if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount'))
    Tools::redirect('index.php?controller=address'); // if registration type is in two steps, we redirect to register address
if ($back = Tools::getValue('back'))
    Tools::redirect($back); //this redirect works only if there is the parameter back
Tools::redirect('index.php?controller=my-account');
if (count($this->context->cart->getProducts(true)) > 0)
    Tools::redirect('index.php?controller=order&multi-shipping='.(int)Tools::getValue('multi-shipping')); // redirection: if cart is not empty : redirection to the cart
else
    Tools::redirect('index.php?controller=my-account'); // else : redirection to the account

 

copied from: http://blog.belvg.com/how-to-redirect-users-to-another-page-after-login-in-prestashop.html

author:

[moderator action] i changed the topic title to clarify the problem.

Link to comment
Share on other sites

×
×
  • Create New...