Post by Qphoria » Fri Feb 12, 2010 3:54 am

Sometimes when working with the admin panel, after a while your session times out and you have to log back in. If you had the product list page open and an hour later you come back to click on "Edit"... the cart redirects you to the login page to relogin. But after logging in, it takes you right to the Admin Home page instead of the original target of product edit.

This mod will persist that initial target after logging in. So when you click edit... if you are redirected to login... after logging it, you will go back to that product you were about to edit. Saves much frustrating time than having to renavigate.

This was one of the best features of OpenCart 0.x but was removed in 1.x. This adds it back

(Should work with All versions)
1. EDIT: admin/controller/common/login.php

2. FIND:

Code: Select all

if (($this->request->post) && ($this->validate())) { 
	  $this->redirect($this->url->https('common/home'));
}
3. REPLACE WITH:

Code: Select all

// Q: Redirect to initial target
		if (($this->request->post) && ($this->validate())) { 
	  		if (isset($_SERVER['HTTP_REFERER'])) {
	  			$this->redirect($_SERVER['HTTP_REFERER']);
			} else {
				$this->redirect($this->url->https('common/home'));
			}
		}//
Last edited by i2Paq on Thu Oct 14, 2010 12:10 am, edited 1 time in total.
Reason: Topic moved

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by dramony » Sat May 15, 2010 12:04 pm

Hello Q,

May i ask, what about if a new customer already chosen a product then suddenly decides to Login/Register?
How can we redirect the customer back to that product after login?

Thank you!

Active Member

Posts

Joined
Sat Oct 24, 2009 12:34 pm

Post by Qphoria » Sat May 15, 2010 11:14 pm

If a customer already added a product to their cart then they wouldn't really need to go back to that page. They are taken to their cart normally

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by dramony » Mon May 17, 2010 9:46 am

Okay, thank you.

Active Member

Posts

Joined
Sat Oct 24, 2009 12:34 pm

Post by jty » Sat Oct 02, 2010 7:12 pm

Is there something like this for 1.4.9.1.1
I tried the above solution for 1.4.9 but no can do.

I am looking for the equivalent of the alleged bug that was in 0.7.9 where I could put in a search criteria in Admin > Product.
Then I could click on something else, say categories (in Admin). Then come back to product list and my search criteria is still there, thereby saving me having to enter my search words again.
They really shouldn't fix "good" bugs.

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by Nakano » Thu Dec 02, 2010 3:44 pm

qphoria, the code you mentioned is not to be found in 1.4.9.2.
Instead, the closest thing I can find is within public function index(), which at least has this:

Code: Select all

if ($this->user->isLogged() && isset($this->request->get['token']) && ($this->request->get['token'] == $this->session->data['token'])) {
			$this->redirect(HTTPS_SERVER . 'index.php?route=common/home&token=' . $this->session->data['token']);
		}

		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { 
			$this->session->data['token'] = md5(mt_rand()); 
		
			if (isset($this->request->post['redirect'])) {
				$this->redirect($this->request->post['redirect'] . '&token=' . $this->session->data['token']);
			} else {
				$this->redirect(HTTPS_SERVER . 'index.php?route=common/home&token=' . $this->session->data['token']);
			}
		}
What changes should we apply?

And what bothers me a bit looking at both these codes, is the https factor. What if I don't have HTTPS enabled on server?

Newbie

Posts

Joined
Sat Sep 18, 2010 6:54 am

Post by megahuman » Tue Feb 15, 2011 7:40 pm

Has anyone figured out if its already in 1.4.9.3? Because I cannot find it! :( Really want this because mine logs out...

Web Design and Development at 7 Design


Active Member

Posts

Joined
Tue Dec 14, 2010 4:57 pm

Post by Qphoria » Tue Feb 15, 2011 8:53 pm

HTTPS will use HTTP if not using HTTPS.
This redirect code is already in the core since 1.4.8

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 13 guests