Post by tora0515 » Wed Oct 17, 2012 9:30 am

Title about sums it up.

Something like this

If (customer came from a different page on my site) {
redirect back to that page;
} else {
redirect as usual;
}

Any ideas on this?

Active Member

Posts

Joined
Fri Jun 15, 2012 3:05 pm

Post by tora0515 » Thu Oct 18, 2012 12:42 pm

bump

Active Member

Posts

Joined
Fri Jun 15, 2012 3:05 pm

Post by Avvici » Thu Oct 18, 2012 12:44 pm

The first thing you do is set up the url in a session variable on the page you are trying to go to. For example if you are trying to go to your account section then in the account.php control file just add:

Code: Select all

$this->session->data['redirect'] = $this->url->link('account/account', '', 'SSL'); 
Now in the login.php control just add the redirect after a successful login. Fill it in with the session variable:

Code: Select all

$this->redirect($this->session->data['redirect']);
or if you have ampersands involved

Code: Select all

$this->redirect(str_replace('&', '&', $this->request->post['redirect'])); 

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by tora0515 » Thu Oct 18, 2012 3:25 pm

Since I won't know what page the user will come from, I should put

Code: Select all

$this->session->data['redirect'] = $this->url->link('account/account', '', 'SSL');
at the top of each tpl file, with account/account being changed?

Active Member

Posts

Joined
Fri Jun 15, 2012 3:05 pm

Post by philbydevil » Thu Oct 18, 2012 3:35 pm

I would suggest going with a "header login" extension. So, the customer can be on any page and log in directly from the header, staying on the same page after login (or being redirected to another page if you wish).

I use this one:
http://www.opencart.com/index.php?route ... on_id=2609

And I use the "stay on same page or redirect to whatever" redirects from this one:
http://www.opencart.com/index.php?route ... on_id=6979

The second one has several redirects set up for different pages (homepage, login page, logout page, everything else).

I heart cmd-f, cmd-c, cmd-v, cmd-z + vQmod.
My favourite page...
v1.5.4.1


User avatar
Active Member

Posts

Joined
Fri Dec 03, 2010 5:20 am

Post by Avvici » Fri Oct 19, 2012 12:23 am

Just use the controler that was given to you to use. You might as well learn how open cart does it by default (because it happens everywhere)

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by imdevlper18 » Sat Jun 09, 2018 2:58 am

An extension for this on the Opencart.
https://www.opencart.com/index.php?rout ... n_id=13998

It has 3 features: Page after login. Page after logout. Plus Strict Login.

Opencart Extensions | Professional opencart support | Support Ticket | support@cartbinder.com


User avatar
Active Member

Posts

Joined
Sun May 11, 2014 2:04 pm

Post by boxaltcoin » Sun Mar 20, 2022 1:55 am

You would need to edit catalog/controller/account/login.php

find for this

Code: Select all

if ($this->customer->isLogged()) {
        $this->response->redirect($this->url->link('account/account', '', true));
    }
and replace it by

Code: Select all

 if ($this->customer->isLogged()) {  
     $this->response->redirect($this->url->link('account/account', '', 'ture'));
}elseif(!isset($this->session->data['redirect']) && isset($_SERVER['HTTP_REFERER'])){
$this->session->data['redirect'] = $_SERVER['HTTP_REFERER'];
}
Worked for me

Newbie

Posts

Joined
Tue Mar 15, 2022 12:56 am

Post by straightlight » Sun Mar 20, 2022 3:33 am

boxaltcoin wrote:
Sun Mar 20, 2022 1:55 am
You would need to edit catalog/controller/account/login.php

find for this

Code: Select all

if ($this->customer->isLogged()) {
        $this->response->redirect($this->url->link('account/account', '', true));
    }
and replace it by

Code: Select all

 if ($this->customer->isLogged()) {  
     $this->response->redirect($this->url->link('account/account', '', 'ture'));
}elseif(!isset($this->session->data['redirect']) && isset($_SERVER['HTTP_REFERER'])){
$this->session->data['redirect'] = $_SERVER['HTTP_REFERER'];
}
Worked for me
ture
I doubt this would work as intended. true case should be used. Also to replace: $_SERVER with: $this->request->server .

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by IP_CAM » Sat Mar 26, 2022 7:07 pm

this->response->redirect($this->url->link('account/account', '', 'ture'));
should most likely look like this:
this->response->redirect($this->url->link('account/account', '', 'true'));

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by straightlight » Sun Mar 27, 2022 1:06 am

Redundancy.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: Amazon [Bot] and 178 guests