If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / Can I change the "back to shopping" behaviour?

Can I change the "back to shopping" behaviour?

Locked

Started by adelante on 29 Apr 2007, 9:51 PM · Views: 8,627

Results 21 to 37 of 37
This thread is locked. New replies are disabled.
14 Aug 2008, 5:11 PM
#21
dontknowwhatimdoing avatar

dontknowwhatimdoing

Zen Follower

Join Date:
Aug 2008
Posts:
131
Plugin Contributions:
0

Can I change the "back to shopping" behaviour?

Too bad no one seems interested in this thread :(

14 Aug 2008, 5:29 PM
#22
dontknowwhatimdoing avatar

dontknowwhatimdoing

Zen Follower

Join Date:
Aug 2008
Posts:
131
Plugin Contributions:
0

Re: Can I change the "back to shopping" behaviour?

Ok--here's a solution that works for me...

the other 'fix' here, wasn't a fix at all, I've got a complex site with many category levels.... etc.

Ok, here's the code I started with in the file: tpl_shopping_cart_default.php
<div class="buttonRow back"><?php echo zen_back_link() . zen_image_button(BUTTON_IMAGE_CONTINUE_SHOPPING, BUTTON_CONTINUE_SHOPPING_ALT) . '</a>'; ?></div>

Now, here's what I changed it to:
<div class="buttonRow back"><a href="<?php echo zen_href_link(FILENAME_DEFAULT, "cPath=$cPath"); ?>"><?php echo zen_image_button(BUTTON_IMAGE_CONTINUE_SHOPPING, BUTTON_CONTINUE_SHOPPING_ALT); ?></a></div>

Works perfectly for me, gets right back to the category of the last product I added to the cart.

14 Aug 2008, 5:37 PM
#23
dontknowwhatimdoing avatar

dontknowwhatimdoing

Zen Follower

Join Date:
Aug 2008
Posts:
131
Plugin Contributions:
0

Re: Can I change the "back to shopping" behaviour?

dontknowwhatimdoing:

Ok--here's a real solution...

the other 'fix' here, wasn't a fix at all, I've got a complex site with many category levels.... etc.

Ok, here's the code you start with in the file: tpl_shopping_cart_default.php
<div class="buttonRow back"><?php echo zen_back_link() . zen_image_button(BUTTON_IMAGE_CONTINUE_SHOPPING, BUTTON_CONTINUE_SHOPPING_ALT) . '</a>'; ?></div>

Now, here's what you change it to:
<div class="buttonRow back"><a href="<?php echo zen_href_link(FILENAME_DEFAULT, "cPath=$cPath"); ?>"><?php echo zen_image_button(BUTTON_IMAGE_CONTINUE_SHOPPING, BUTTON_CONTINUE_SHOPPING_ALT); ?></a></div>

Works perfectly for me, gets right back to the proper listing.

Turns out this is a halfway solution. It only works if someone uses the "add to cart button". If they view the product listing first, it does not work.

Here's a good question I think: how can I make sure the $cpath variable gets loaded if someone is adding to cart from a product listing?

14 Aug 2008, 5:49 PM
#24
dontknowwhatimdoing avatar

dontknowwhatimdoing

Zen Follower

Join Date:
Aug 2008
Posts:
131
Plugin Contributions:
0

Re: Can I change the "back to shopping" behaviour?

Blah, blah, blah...ignore everything else I wrote (unless you have a proper PHP solution, then cough it up!)

Ok--the only solution I can come up with, is just a simple javascript back. If the user has javascript disabled, then oh well.

Nothing else works 100% or even 60% properly for me.

You can see the old version of the button link above, here's the new version:
<div class="buttonRow back"><a onclick="javascript:history.go(-1)"><?php echo zen_image_button(BUTTON_IMAGE_CONTINUE_SHOPPING, BUTTON_CONTINUE_SHOPPING_ALT); ?></a></div>

Notice.. I didn't include <a href="...

The reason is, I think it looks a bit sloppy, so I just buried the function inside an onclick function.

If I clean up my store URLs, I might do this to a lot of buttons if I'm too lazy to fix internal links...

Sneaky, sneaky, sneaky...

4 Dec 2008, 1:42 PM
#25
mydanilo avatar

mydanilo

Totally Zenned

Join Date:
Dec 2004
Posts:
1,024
Plugin Contributions:
0

Re: Can I change the "back to shopping" behaviour?

Just want to say thank you! I never had time to do it earlier but I have this installed on all carts I maintain. This is a must! What good is it if you put something in your cart and after you want to go back shopping and you get bounced to the home page? Most likely I would like to continue where I left off shopping. Right?

Its like at the brick and mortar store they would send you back to the door every time you put something in the shopping basket!

Feature should be standard behavior. :clap:

Live and learn... the Zen way.

11 Dec 2008, 4:30 PM
#26
vrtisworks avatar

vrtisworks

New Zenner

Join Date:
Apr 2005
Posts:
3
Plugin Contributions:
0

Re: Can I change the "back to shopping" behaviour?

I haven't tested it completely, and I've got way too much extra code to verify it works on a "normal" site, but it looks like the problem is in

"includes/functions/functions_general.php"

around lines 992 and 1010, there is
if (sizeof($_SESSION['navigation']->path)-2 > 0) {

I changed this to be
if (sizeof($_SESSION['navigation']->path)> 1) {

and then the continue shopping button took me back to the page I was looking at when I added the product to the cart....

Your results may vary.. but it's something to try....

18 Dec 2008, 9:23 PM
#27
majikins avatar

majikins

New Zenner

Join Date:
Nov 2008
Posts:
9
Plugin Contributions:
0

Re: Can I change the "back to shopping" behaviour?

vrtisworks:

I haven't tested it completely, and I've got way too much extra code to verify it works on a "normal" site, but it looks like the problem is in

"includes/functions/functions_general.php"

around lines 992 and 1010, there is
if (sizeof($_SESSION['navigation']->path)-2 > 0) {

I changed this to be
if (sizeof($_SESSION['navigation']->path)> 1) {

and then the continue shopping button took me back to the page I was looking at when I added the product to the cart....

Your results may vary.. but it's something to try....

thank you! :clap:

Its working perfectly for me so far.

3 Feb 2009, 4:05 AM
#28
druber avatar

druber

New Zenner

Join Date:
Jan 2009
Location:
Syracuse, IN
Posts:
3
Plugin Contributions:
0

Re: Can I change the "back to shopping" behaviour?

dontknowwhatimdoing:

You can see the old version of the button link above, here's the new version:
<div class="buttonRow back"><a onclick="javascript:history.go(-1)"><?php echo zen_image_button(BUTTON_IMAGE_CONTINUE_SHOPPING, BUTTON_CONTINUE_SHOPPING_ALT); ?></a></div>

Man, this is sooo cool! I've been trying to figure out how to do this for hours! Thank you!
Druber

16 Feb 2009, 4:21 PM
#29
doodlebee avatar

doodlebee

Inactive

Join Date:
Jan 2006
Posts:
228
Plugin Contributions:
0

Re: Can I change the "back to shopping" behaviour?

I just wanted to say that when I added Adelante's code to the site I'm working on, it broke my product listing index pages.

In case it happens to anyone else, it's because of the comments. Session data truly must be the FIRST thing that shows up on a page. Stuff that is commented out is okay, BUT he's using HTML comments, not PHP. Therefore HTML is showing up before the session data - and breaking the pages.

To fix it, just replace his original code with this:

<?php // reset the session variable
unset($_SESSION["last_category_visited"]);
// change the variable from "last category visited" to "current product category number"
session_start();
$_SESSION["last_category_visited"] = $current_category_id;
?>

note how now the comments are within the PHP tags - so the session data is still first in line. It works like a charm now.

6 May 2009, 12:49 AM
#30
harrylshulman avatar

harrylshulman

New Zenner

Join Date:
May 2009
Posts:
1
Plugin Contributions:
0

Re: Can I change the "back to shopping" behaviour?

vrtisworks:

I haven't tested it completely, and I've got way too much extra code to verify it works on a "normal" site, but it looks like the problem is in

"includes/functions/functions_general.php"

around lines 992 and 1010, there is
if (sizeof($_SESSION['navigation']->path)-2 > 0) {

I changed this to be
if (sizeof($_SESSION['navigation']->path)> 1) {

and then the continue shopping button took me back to the page I was looking at when I added the product to the cart....

Your results may vary.. but it's something to try....

Is there a way to have the button take you to a specific URL instead of just going back?

6 May 2009, 8:59 PM
#31
vrtisworks avatar

vrtisworks

New Zenner

Join Date:
Apr 2005
Posts:
3
Plugin Contributions:
0

Re: Can I change the "back to shopping" behaviour?

Technically.... Yes. If you look at the statements following the IF statements, they set $link=<a ... then, the back button can be made to go anywhere.

I suspect that it would be confusing to the user if the Back button did not take them back to where they were, but off to some other page though.

10 Sep 2009, 10:33 AM
#32
out2lunch avatar

out2lunch

New Zenner

Join Date:
Jul 2008
Posts:
64
Plugin Contributions:
0

Re: Can I change the "back to shopping" behaviour?

harrylshulman:

Is there a way to have the button take you to a specific URL instead of just going back?

Yea this is what I changed the line to, as I wanted to go back to the home page, but just change the url to what ever you desire.

Original Code and File: /includes/templates/template_default/templates tpl_shopping_cart_default.php

<div class="buttonRow back"><?php echo zen_back_link() . zen_image_button(BUTTON_IMAGE_CONTINUE_SHOPPING, BUTTON_CONTINUE_SHOPPING_ALT) . '</a>'; ?></div>

Changed to -

<div class="buttonRow back"><?php echo '<a href="index.php">' . zen_image_button(BUTTON_IMAGE_CONTINUE_SHOPPING, BUTTON_CONTINUE_SHOPPING_ALT) . '</a>'; ?></div>
6 Nov 2009, 6:40 AM
#33
australican avatar

australican

Zen Follower

Join Date:
Jan 2009
Location:
Victoria Australia
Posts:
100
Plugin Contributions:
0

Re: Can I change the "back to shopping" behaviour?

Thanks to adelante... I tried a few fixes for this and his suited my needs best.
I would have never figured that out myself.
Only thing is that it is not working if I viewed, then added to cart from a dynamically generated category. I.E. All Products.
If I have previously added a product from a defined category it returns there instead.
I suspect it has to do with the fact that the categories are dynamically generated, or perhaps it's something to do with my URI re-write module.

If anyone has figured out how to get this to work, I would greatly appriciate some advise.
David

countrytothecore.net

6 Nov 2009, 9:01 AM
#34
adelante avatar

adelante

New Zenner

Join Date:
May 2006
Location:
QLD Australia
Posts:
73
Plugin Contributions:
0

Re: Can I change the "back to shopping" behaviour?

I'm glad the little mod has been useful. australican I think it's because you're you actually in a category, personally I don't use the show all products menu item. I'll have to re-vist the code and have a look again.

7 Nov 2009, 12:17 AM
#35
australican avatar

australican

Zen Follower

Join Date:
Jan 2009
Location:
Victoria Australia
Posts:
100
Plugin Contributions:
0

Re: Can I change the "back to shopping" behaviour?

My little e-shop is an extension of our little B&M gift shop and fairly new. I'm still just testing really. I've never been an online shopper so I don't know how many shoppers would use All or New categories yet, but would still like to clean up that loose end.
Personally All seems silly, especially for shops with large amounts of products. It's probably intended for shop with only a dozen or so items.
I like to give people as many options as possible, but too many might just lead to confusion.
Anyone else have an opinion or words of wisdom on this?
(Not that yours wasn't relevant adelante)

Anywho... Thanks again for the little mod.
David

20 Jan 2010, 6:21 AM
#36
kechjones avatar

kechjones

New Zenner

Join Date:
Nov 2008
Posts:
3
Plugin Contributions:
0

Re: Can I change the "back to shopping" behaviour?

Thanks to everyone on this thread. You just saved me hours of digging and experimenting and frustration.

19 May 2010, 10:05 AM
#37
sushigal avatar

sushigal

Zen Follower

Join Date:
Mar 2009
Posts:
435
Plugin Contributions:
0

Re: Can I change the "back to shopping" behaviour?

brilliant exactly what I wanted to do, have the button just go 'back' :-) thanks!

But...only problem is, the buttons there (ive made my own) it goes back when you click on it but on the hover over it doesnt change, looks like an inactive button that doesnt link to anything only when you click it does it actually work. Any ideas?