Post by Karen » Fri Jul 23, 2010 5:30 am

Instead of taking the user back to the home page, I want those "continue" and "continue shopping" buttons to be back buttons for the barely-web-literate. (All except the ones inside the checkout process itself, of course).

Can anyone tell me how to change this? Is it on a template-by-template basis?

Found this answer from a year ago, though Daniel had said he would add it to the next release. Is this still the best answer?

http://forum.opencart.com/viewtopic.php ... 574#p27486
Last edited by i2Paq on Sat Jul 24, 2010 3:34 am, edited 1 time in total.
Reason: Topic moved

Using OC version 1.4.8b
http://catandcaboodle.com/


User avatar
Active Member

Posts

Joined
Thu Jun 10, 2010 2:51 pm
Location - WA State, USA

Post by Karen » Fri Jul 23, 2010 6:30 am

Based on the above, I have found 4 controller files I think I'd want to change. Before I totally nuke my cart, can someone tell me whether this is the right coding to change, and the right change to make?

catalog/controller/checkout/cart.php
catalog/controller/error/not_found.php
catalog/controller/information/information.php

For every instance in the above files where the code reads

Code: Select all

$this->data['continue'] = HTTP_SERVER . 'index.php?route=common/home';
I would substitute:

Code: Select all

$this->data['continue'] = HTTP_SERVER . "history.back()";
Yes, no? Is there a space, a period, or quote marks out of place here?

Thanks in advance, all you coding wizards.
Last edited by Karen on Sat Jul 24, 2010 2:56 am, edited 1 time in total.

Using OC version 1.4.8b
http://catandcaboodle.com/


User avatar
Active Member

Posts

Joined
Thu Jun 10, 2010 2:51 pm
Location - WA State, USA

Post by JAY6390 » Fri Jul 23, 2010 7:38 am

Code: Select all

$this->data['continue'] = HTTP_SERVER . "history.back()"; 
should be

Code: Select all

$this->data['continue'] = "history.back()"; 

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by Karen » Fri Jul 23, 2010 10:00 am

Hmmm, that doesn't work, either. Instead of trying to go back, it tries to go to http://www.mydomain.com/history.back(), which of course doesn't exist.

In poking around the web, I found some (admittedly old) info on Webmaster World: "If you use sessions then just remember the last page in your session container and use that URI." I don't know what that means, but I did see some code in those controller files about sessions.

I also saw the warning about: "I´d use the $_SERVER['HTTP_REFERER'] superglobal just to be sure. Checking whether the referrer is a valid URI and on your domain might be a good idea as well. After all this could be anything, so simply echoing it will open up your site to all kinds of code injections vulnerabilities."

Apparently this coding of a back button is way more complicated than I thought ???
But I'd still like to do it if someone can give me the answers.

User avatar
Active Member

Posts

Joined
Thu Jun 10, 2010 2:51 pm
Location - WA State, USA

Post by fido-x » Fri Jul 23, 2010 4:01 pm

Don't add the "history.back()" into the controller. Do it in the template file.
Change:

Code: Select all

<a onclick="location = '<?php echo str_replace('&', '&', $continue); ?>'" class="button">
to:

Code: Select all

<a onclick="history.back();" class="button"> 

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by mystifier » Fri Jul 23, 2010 4:51 pm

I use back buttons in several pages as follows which works great:

Code: Select all

<a href="javascript:history.go(-1)"  onMouseOver="self.status=document.referrer;return true" class="button"><span>Continue</span></a>   
(I am not clever enough to write this by the way... I got it from somewhere else).

Free v1.4.9 Extensions: Default Specials | Improved Search | Customer Activity Report | Customer Groups | Royal Mail With Handling | Improved Product Page | Random Products | Stock Report | All Products


User avatar
Active Member

Posts

Joined
Tue May 18, 2010 5:15 pm

Post by Karen » Sat Jul 24, 2010 2:32 am

Thanks to both of you!

I'll give these a try.

Using OC version 1.4.8b
http://catandcaboodle.com/


User avatar
Active Member

Posts

Joined
Thu Jun 10, 2010 2:51 pm
Location - WA State, USA

Post by fido-x » Sat Jul 24, 2010 12:00 pm

My personal choice would be to use the "onclick" method rather than the "href" method, simply because the "onclick" hides the link, whereas the "href" displays the link in the status bar at the bottom of your browser window.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by Karen » Sat Jul 24, 2010 1:34 pm

Thanks for the info. I did use the onclick, because it was a straight substitution. I really appreciate all the help (and so will everyone else who's looking to do this)!

User avatar
Active Member

Posts

Joined
Thu Jun 10, 2010 2:51 pm
Location - WA State, USA
Who is online

Users browsing this forum: No registered users and 47 guests