Forums / General Questions / Product listing page "add to cart" button redirects to product info

Product listing page "add to cart" button redirects to product info

Started by mikey_d on 7 Mar 2016, 3:59 PM · Views: 2,728

Results 1 to 18 of 18
7 Mar 2016, 3:59 PM
#1
mikey_d avatar

mikey_d

New Zenner

Join Date:
Jan 2012
Location:
Canada
Posts:
16
Plugin Contributions:
0

Product listing page "add to cart" button redirects to product info

I think that is the default set-up, but I can't seem to get it the way I want, no matter how much I search.
Basically, I want the product listing page to refresh when someone adds something to the cart. That button should keep you on the same page.
I played with the appropriate settings to no avail.
"Display Multiple Products Qty Box Status and Set Button Location" is set to "0" off
"Display Product Add to Cart Button" is set to "2" on with QTY box
"Display Cart After Adding Product" I have set to false

Here a link to see for you to see for yourself.
standard stainless steel flat head square tapping screw

I've searched through these forums and found similar problems, but none of those fixes seemed to work

7 Mar 2016, 4:39 PM
#2
haredo avatar

haredo

Totally Zenned

Join Date:
Apr 2006
Location:
Texas
Posts:
6,188
Plugin Contributions:
0

Re: Product listing page "add to cart" button redirects to product info

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.

Zen Cart Certified hosting at myZenCartHost.com.

7 Mar 2016, 4:41 PM
#3
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,120
Plugin Contributions:
56

Re: Product listing page "add to cart" button redirects to product info

What you are describing is not "standard" Zen Cart behavior, as controlled by /includes/init_includes/init_cart_handler.php (it's the $goto variable setting that's of interest).

Has that file been overwritten by one of the plugins (or template) that you are using?

7 Mar 2016, 6:20 PM
#4
mikey_d avatar

mikey_d

New Zenner

Join Date:
Jan 2012
Location:
Canada
Posts:
16
Plugin Contributions:
0

Re: Product listing page "add to cart" button redirects to product info

Well I replaced the init_cart_handler with the original file for 1.5.4. I checked to see if there was an override file for it, there was one. But I had made it in the last few days while following a fix in the forum here. I removed it and no improvement. Still going to the info page.
Maybe I do have a add-on messing with this, but I can't imagine what. Can you think of some thing to search for that might help me track down the problem?
I searched for $goto and couldn't find anything fishy.

7 Mar 2016, 6:37 PM
#5
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Product listing page "add to cart" button redirects to product info

To be sure of understanding what you have been seeing is that when there is a list of products, the add to cart adjacent to that product adds the product to the cart, but then returns the customer to the info page for that one product.

What you would like to have is a list of products, selecting to add products adds the items, but returns to the list of products.

Been a while and I don't currently have immediate access to test, but what about using the "Display Multiple Products Qty Box Status and Set Button Location" set to 1, 2, or 3?

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

7 Mar 2016, 6:51 PM
#6
mikey_d avatar

mikey_d

New Zenner

Join Date:
Jan 2012
Location:
Canada
Posts:
16
Plugin Contributions:
0

Re: Product listing page "add to cart" button redirects to product info

Good point mc12345678,
I did test that. When I had it setup for "Multiple Products QTY" It would redirect to the same page. The problem was my "buy now" button disappeared.

7 Mar 2016, 7:36 PM
#7
patclay avatar

patclay

New Zenner

Join Date:
Dec 2008
Location:
New Zealand
Posts:
88
Plugin Contributions:
1

Re: Product listing page "add to cart" button redirects to product info

I think that ZC is doing exactly what you instructed, but you are not paying attention (or I could be wrong, it has happened before :D).

When I go to the page and click add to cart, it adds the product to the cart, and then goes to the product page.

The problem is that it isn't really obvious that the product has been added to the cart, and going to the product page looks almost like what it would do if there was some type of error, so you click 'add to cart' again.

Change "Display Cart After Adding Product" to true, and I think that will make your problem go away. I know that you turned it to false for a reason, but test to see if that is causing your behaviour & then see if you still agree with your reason.

7 Mar 2016, 8:14 PM
#8
mikey_d avatar

mikey_d

New Zenner

Join Date:
Jan 2012
Location:
Canada
Posts:
16
Plugin Contributions:
0

Re: Product listing page "add to cart" button redirects to product info

:blink: I don't see how that would work, but I'll try it!

So, it just took me to the shopping cart after adding an item from the product page.
not the easy fix I was hoping for haha

Could it have anything to do with the green banner that says you've successfully added the item to the cart?

7 Mar 2016, 9:04 PM
#9
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Product listing page "add to cart" button redirects to product info

Mikey D:

:blink: I don't see how that would work, but I'll try it!

So, it just took me to the shopping cart after adding an item from the product page.
not the easy fix I was hoping for haha

Could it have anything to do with the green banner that says you've successfully added the item to the cart?

Actually, that banner ought to provide a good indication that the product has been added to the cart... Since it says that...

Now, I got to thinking and a while back someone had a slightly different request, but perhaps with proper merging, it can be incorporated and serve the end goal you are trying to obtain, but let me explain first.

So, the "Display Multiple Products Qty Box Status and Set Button Location" set to a value other than 0, removes the Add-to-cart button... Makes sense to an extent as one need only populate the quantity desired for each item and then select the button that is located top, bottom, or both to fill the cart with that quantity of those items. The add-to-cart button addresses the one item and isn't really looking at where it "was"... So, what about something somewhat in the middle of the road? What about an increase/decrease button?

Check out: Checkbox TextBox Icon Product Checkout

The idea is/was that an icon would be available to click on to increase or decrease the quantity of the product in the cart and stay on the same page... Of course this is before the use of things like javascript or ajax... :)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

7 Mar 2016, 9:47 PM
#10
mikey_d avatar

mikey_d

New Zenner

Join Date:
Jan 2012
Location:
Canada
Posts:
16
Plugin Contributions:
0

Re: Product listing page "add to cart" button redirects to product info

I see what your saying, but that's not the setup what I was hoping for. I want someone to fill in the field, click add to cart, have the listing page refreshed with the little green banner on top. I don't see how that addon would fix my redirect. Also, to have it the way I want, I would have to "hide" these icons, which seems a bit redundant.

Maybe I could hack the code a bit. What I was thinking as a work around would be switching it to multiple product QTY. Finding the add to cart button code, or the add multiple product button code. Then adding that button to each listing under the quantity box.
The first problem I see is that if they put any numbers down in another field, and forget about it, then choose another item and input the amount, both will be added to the cart. I would also have to change the default quantity in that box to zero instead of 1 or whatever.
Can you imagine any other pitfalls?

hmmm maybe I'll take a closer look at that add multiple items button. There must be something there that keeps it on the same page.

BTW Thanks for your help on this today! :D

8 Mar 2016, 12:05 AM
#11
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Product listing page "add to cart" button redirects to product info

So the plugin resolves the issue of opening the product info page upon increasing/decreasing the quantity by well, not doing so. As stated in the plugin/forum thread, the images are not the top pick, but that can be resolved by using the picture of choice.

To me it seems like it resolves the general issue, and perhaps some modification to further get what you're looking.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

8 Mar 2016, 2:54 AM
#12
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Re: Product listing page "add to cart" button redirects to product info

mikey,
allow me to throw my 2 cents in but you already have members of the a-team on the case.

it seems that the ajax-to-cart functionality would resolve your problem, as you would just stay on the current page without even a need to refresh the whole page. when i go to your page, and add something to the cart, i see EXACTLY the behavior that you are talking about. i also see some console errors that suggest to me you "might" already have that ajax add-to-cart functionality in your responsive avonlee contempo template but you are not loading jquery prior to that call. so your jquery call fails and then you are going to some default behavior that might be addressed via a configuration setting that others have talked about.

i know nothing about that template, but i "think" if you get those console errors addressed, everything might work exactly the way you want it. (you can see console errors via developer tools which are mostly accessed by pressing the F12 key when on your page, although it varies based on what browser you are using.)

good luck!

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

8 Mar 2016, 8:36 PM
#13
mikey_d avatar

mikey_d

New Zenner

Join Date:
Jan 2012
Location:
Canada
Posts:
16
Plugin Contributions:
0

Re: Product listing page "add to cart" button redirects to product info

Thanks, I fixed up some of those bugs you pointed out. Jquery wasn't loading before my other scripts. That didn't resolve my issue.

I don't seem to have Ajax-to-cart, so I tried installing the addon you mentioned. It's giving me a few problems, that might be my template and my mods messing with it. It doesn't display the cart contents, and there's no pop-up explaining anything has been added to the cart. Also, I have to modify it to work on the product listing page.

If my zen-cart isn't reloading the page the way it's supposed to in the first place, I don't see how any number of addons will make it start working again. Something has to be in there changing the way Zencart should be working right? It's just seems like a lot of work modifying addons just to see if they work in my scenario.
Sorry I'm just a little frustrated at the moment. You guys have been very helpful, and I appreciate your responses.

9 Mar 2016, 12:18 AM
#14
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Re: Product listing page "add to cart" button redirects to product info

Mikey D:

If my zen-cart isn't reloading the page the way it's supposed to in the first place, I don't see how any number of addons will make it start working again. Something has to be in there changing the way Zencart should be working right? It's just seems like a lot of work modifying addons just to see if they work in my scenario.
Sorry I'm just a little frustrated at the moment. You guys have been very helpful, and I appreciate your responses.

mikey d,
no need to apologize. i think we have all been there.

with regards to the statement above, when working properly an ajax request will "hijack" the click to add to cart and do something else, so if you could get the ajax request to work, it would not matter that the other part does not work the way you want to it.... except for those users on older browsers who do not use javascript. but getting ajax requests to work can be a lot of work. and i'm still seeing some weird jquery error on the console.

you can tell if you have the Ajax Add to Cart module installed if there is a menu item for it on the admin -> configuration pulldown. but again, in my experience, ajax requests get more complex.

let's if we can point you in a better direction. with regards to how you are configured and what you want it to do, i'm not sure any of the ZC configurations will change it. i could be wrong... and if someone knows better, by all means chime in....

i've reviewed all of the comments. let's see if we get this right:

  • you don't want to go to the shopping cart after adding something. the DISPLAY_CART configuration is set to false. all good.
  • you are NOT making use of the multiple_products_cart_quantity form. you do not like this because you then lose your add to cart button associated with each item on the category display. if you made use of this form, which only has a button on the top of the form and bottom of the form, the resulting behavior would be what you want.
  • instead you are using the cart_quantity form which gives you the add-to-cart button, but instead of refreshing this page, you end up on the product information page.

and there is the dilemma. you like those individual buttons which are only available with the cart_quantity form, but you want the resulting page to be the result of the multiple_add_to_cart form. i think that is correct, please let me know if not...

in looking at the code, i'm not sure ZC will do what you want without making some custom changes. it looks like you would need to change the:

includes/modules/product_listing.php

script; which may be overridden already and be here:

includes/modules/responsive_avonlee_contempo/product_listing.php

(i have zero experience with this template.)

i'm going to take a wild shot on this one. you might be able to change the code as below, and this might work. no guarantees. around line 136 look for:

 $lc_button= zen_draw_form('cart_quantity', zen_href_link($_GET['main_page'], zen_get_all_get_params(array('action')) . 'action=add_product&products_id=' . $listing->fields['products_id']), 'post', 'enctype="multipart/form-data"') . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($listing->fields['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_draw_hidden_field('products_id', $listing->fields['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</form>';

// change to:

 $lc_button= zen_draw_form('cart_quantity', zen_href_link(FILENAME_DEFAULT, zen_get_all_get_params(array('action')) . 'action=add_product&products_id=' . $listing->fields['products_id']), 'post', 'enctype="multipart/form-data"') . '<input type="text" name="cart_quantity" value="' . (zen_get_buy_now_qty($listing->fields['products_id'])) . '" maxlength="6" size="4" /><br />' . zen_draw_hidden_field('products_id', $listing->fields['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '</form>';

you are only changing the $_GET['main_page'] to FILENAME_DEFAULT.

without having a test server set up the exact way here you have it, i can not tell you if it will work, but it could be worth a shot.

good luck!

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

9 Mar 2016, 1:09 PM
#15
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,120
Plugin Contributions:
56

Re: Product listing page "add to cart" button redirects to product info

What happens if you (temporarily) disable your URL rewriter? Does the problem persist?

I keep poking because a fresh Zen Cart install with a change to Configuration->My Store->Display Cart After Adding Product set to false (see http://vinosdefrutastropicales.com/demo/index.php?main_page=index&cPath=2_20&sort=20a) provides the functionality you're looking for. When you click the "add multiple" button, the items are added to the cart and the listing page is redisplayed.

That demo site is a "slightly-modified" Zen Cart v1.5.4 site.

9 Mar 2016, 1:35 PM
#16
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Product listing page "add to cart" button redirects to product info

lat9:

What happens if you (temporarily) disable your URL rewriter? Does the problem persist?

I keep poking because a fresh Zen Cart install with a change to Configuration->My Store->Display Cart After Adding Product set to false (see http://vinosdefrutastropicales.com/demo/index.php?main_page=index&cPath=2_20&sort=20a) provides the functionality you're looking for. When you click the "add multiple" button, the items are added to the cart and the listing page is redisplayed.

That demo site is a "slightly-modified" Zen Cart v1.5.4 site.

Two things related to the above link and a third related to the issue.

  1. The selection of multiple products top/bottom has been described as not so desired (though does provide the desired response).
  2. Similar to a post I made recently to help another out with their copying of a site/use of a new template/SSL issue, when attempting to add one of the products to the cart from the above link, am presented with a SSL security issue related to bootstrap that the certificate is for a different server/host than against the one "picked up". That's a side issue related to the referenced site and doesn't pertain to the issue of the OP.
  3. I tested operation of adding a product to the cart from product listing using one of my test sites, and obtained the result desired when each product has the add-to-cart button adjacent to it. I know that the plugin I referenced earlier isn't installed (at least the SQL isn't), but now am questioning what other changes were made to the software, because it is responding different than described as "normal". I plan to download a vanilla version of ZC 1.5.4 again to compare against this to see what I had changed on that site if anything and throw the code out there if it was modified. The test location was: http://template3.mc12345678.com/index.php?main_page=index&cPath=64

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

9 Mar 2016, 5:06 PM
#17
mikey_d avatar

mikey_d

New Zenner

Join Date:
Jan 2012
Location:
Canada
Posts:
16
Plugin Contributions:
0

Re: Product listing page "add to cart" button redirects to product info

I figured out the problem, It was a template issue. I was changing things and saw nothing, well that's because of a theme override file i just didn't notice. I was looking for an "override" folder, and wasn't seeing the theme folder in includes/modules. It was coded to keep going to the info page.

The problem is fixed, I now stay on the page, and the banner pops up saying I've added the item to the cart.

Carlwhat, that little bit of code helped me track down and fix the issue. But, everyone's help and patience was super awesome! Thank you!

:D

9 Mar 2018, 2:41 AM
#18
speak394 avatar

speak394

New Zenner

Join Date:
Mar 2018
Location:
Alabama
Posts:
61
Plugin Contributions:
0

Re: Product listing page "add to cart" button redirects to product info

I am having the same problem, which file did you edit to fix your problem?