Step 1
I added the following function to the Controller class in the core. (engine/controller.php)
protected function getcurrenturl() {
$url = 'http://' .$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
return htmlentities(strip_tags($url));
}
Step 2
To store the visited page I use the session. If you want top remember the last visited category page go to catalog/controller/product/category.php and put the following code somewhere (I've put it all the way at the top inside the index function of that class.
$this->session->data['last_page'] = $this->getcurrenturl();
I've also put this in the manufacturer, search and special controllers. If you put it inside the product controller it will off course remember the last visited product. The value of the session gets overwritten whenever a customer visits one of these pages.
Step 3
Go to catalog/controller/checkout/cart.php and replace this:
$this->data['continue'] = HTTP_SERVER . 'index.php?route=common/home';
with this:
if(isset($this->session->data['last_page'])){
$this->data['continue'] = $this->session->data['last_page'];
}else{
$this->data['continue'] = HTTP_SERVER . 'index.php?route=common/home';
}
What it does, it checks if the session has a stored value. If not it redirects to the homepage.
I hope this helps in a better user experience.
OpenCart Developer sinds versie 1.4.9.3. Inmiddels volledige CMS geïntegreerd binnen OC 1.5. Sta open voor uitdagende custom uitbreidingen en custom themes, inclusief responsive design.
GEMAAKT MET OPENCART
http://www.worldofbessy.com
http://www.kiddycolors.com
http://www.ke-works.com
http://www.trendyard.nl
http://www.bigliftshipping.nl
http://www.kosterklokken.nl
OpenCart Developer sinds versie 1.4.9.3. Inmiddels volledige CMS geïntegreerd binnen OC 1.5. Sta open voor uitdagende custom uitbreidingen en custom themes, inclusief responsive design.
GEMAAKT MET OPENCART
http://www.worldofbessy.com
http://www.kiddycolors.com
http://www.ke-works.com
http://www.trendyard.nl
http://www.bigliftshipping.nl
http://www.kosterklokken.nl
Hope this makes sense.
Chris
Regards
Chris
So it's up to you which page URL you want to store, just add this
$this->session->data['last_page'] = $this->getcurrenturl();
to every controller of a page you want to remember in the session. You say naturally they would press the back button in the browser but it would surprise you how much people dont even know this button exists and besides I want to be in control of the user experience within the shop.
I hope this helps. If you have more questions let me know.
OpenCart Developer sinds versie 1.4.9.3. Inmiddels volledige CMS geïntegreerd binnen OC 1.5. Sta open voor uitdagende custom uitbreidingen en custom themes, inclusief responsive design.
GEMAAKT MET OPENCART
http://www.worldofbessy.com
http://www.kiddycolors.com
http://www.ke-works.com
http://www.trendyard.nl
http://www.bigliftshipping.nl
http://www.kosterklokken.nl

Business Cards and other Printing Services provided by CardsMadeEasy!
Contact Us for more information on business card printing!
I did find a couple of issues though with the first change:
Code: Select all
protected function getcurrenturl() {
$url = 'http://' .$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
return htmlentities(strip_tags($url));
}
Code: Select all
$url = 'http://' .$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
Code: Select all
$url = 'http://www.' .$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
Also found that after clicking continue in the cart coming from a search page, it was redirecting me to a URL that I wasn't previously on. It was putting the code for the ampersand '&' rather than just '&' in the URL.
So this:
Code: Select all
index.php?route=product/search&filter_name=searchtext
Code: Select all
index.php?route=product/search&filter_name=searchtext
Code: Select all
return htmlentities(strip_tags($url));
Code: Select all
return ($url);
Google Analytics Expert - Advanced e-commerce tracking, Product & options reporting, transaction/conversion reporting, Google Adwords conversion & profit reporting, goal & funnel reporting, event tracking, site search tracking, multi-store compatibility, EU Cookie Law compliance and works with any theme or checkout! Easy vqmod install. Get it here
Could someone tell me what line this is in V 1.5.3?Step 3
Go to catalog/controller/checkout/cart.php and replace this:
$this->data['continue'] = HTTP_SERVER . 'index.php?route=common/home';
with this:
if(isset($this->session->data['last_page'])){
$this->data['continue'] = $this->session->data['last_page'];
}else{
$this->data['continue'] = HTTP_SERVER . 'index.php?route=common/home';
}
Todd Motto http://www.toddmotto.com | Brand Identity/Graphic Designer & Front-End Web Developer
Appreciate any feedback you guys have!
My Opencart Extensions
My site for installed home products: Home - Windows - Water Heaters -
Furnaces - and more!
You can use this free mod here:theone wrote:hello guys,
can anyone advice how can i implement this to opencart 2.0.3.1 ?
i mean Continue button in the cart should take back to the last visited product page.
thanks very much for your time.
best regards
http://www.opencart.com/index.php?route ... n_id=22989
Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.
Users browsing this forum: No registered users and 2 guests