Forums / General Questions / Problem adding products to cart from product listing page

Problem adding products to cart from product listing page

Started by teaj on 25 Feb 2017, 12:23 PM · Views: 4,371

Results 1 to 16 of 16
25 Feb 2017, 12:23 PM
#1
teaj avatar

teaj

New Zenner

Join Date:
Dec 2007
Location:
South, UK
Posts:
66
Plugin Contributions:
0

Problem adding products to cart from product listing page

Hello, I have an issue when adding products to cart from the product listing page, I've tried a few things to sort it but I'm stuck, I hope someone more knowledgable than I will find it easy to fix....

I am using v155, with many plugins, the most relevant one here would be Attributes on Product Listing.

When I set admin config 'Display Cart After Adding Product' to False and then add a product from the listing page, I get the 'Sorry, the product was not found.' page (but the product is correctly added to cart still).

When I set 'Display Cart After Adding Product' to true, everything works as it should (taken to cart page with product added).

My ideal scenario is the customer remains on the Product Listing page and a small message is displayed saying 'Product added to cart'. It appears the process is trying to redirect to an incorrect path following the add to cart. It seemsto have something to do with this bit of code from the modules/product_listing.php file....

	
		$lc_text = '';
		    $lc_text .= zen_draw_form('add_product_'.$listing->fields['products_id'], 
			                   zen_href_link(zen_get_info_page($listing->fields['products_id']), zen_get_all_get_params(array('action')) . 
							   'action=add_product'), 'post', 'enctype="multipart/form-data"');
       

Which looks something like this when parsed...

 <form name="add_product_103" action="http://bboylaces-dev2.propersafe.net/product_info?cPath=3&sort=20a&number_of_uploads=0&action=add_product" method="post" enctype="multipart/form-data">

It's this URL (action="URL") that it's trying to forward to after adding to cart. So If I could get this to be the current product listing URL, then it should stay on the page?

I hope I've explained that correctly and someone might be able to guide me?

This is a develpoment site the url is - eg - http://bboylaces-dev2.propersafe.net/20mm-xl-fat-laces-c-1

Please excuse any dust, this is being worked on and not been formatted for phones/tablets/certain browsers etc yet.

Many thanks in advance :smile:

25 Feb 2017, 1:07 PM
#2
lat9 avatar

lat9

Administrator

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

Re: Problem adding products to cart from product listing page

Did you recently add the "Attributes on Product Listing" plugin, or did you upgrade an existing site to 1.5.5?

25 Feb 2017, 1:18 PM
#4
lat9 avatar

lat9

Administrator

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

Re: Problem adding products to cart from product listing page

FWIW, I'd tried that plugin a couple of years ago and found that it didn't work then either!

25 Feb 2017, 1:26 PM
#5
teaj avatar

teaj

New Zenner

Join Date:
Dec 2007
Location:
South, UK
Posts:
66
Plugin Contributions:
0

Re: Problem adding products to cart from product listing page

Ah thanks I see! Do you mean you had the same problem I've got? Or it didnt work at all?

Most functionanlity works correctly, which is frustrating... so close to getting it working but just can't get over this last block!

I guess displaying the cart after adding the product is still an improvement but it would be great if customers can add multiple products without leaving the page.

Cheers

25 Feb 2017, 2:03 PM
#6
lat9 avatar

lat9

Administrator

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

Re: Problem adding products to cart from product listing page

I'm pretty sure the issue I ran into is the one that you reported.

The "root cause" lies somewhere in the fact that the default Zen Cart processing, after an add_product action (normally issued from a product_info page) is to return either to that _info page or the shopping_cart.

25 Feb 2017, 2:13 PM
#7
teaj avatar

teaj

New Zenner

Join Date:
Dec 2007
Location:
South, UK
Posts:
66
Plugin Contributions:
0

Re: Problem adding products to cart from product listing page

Thank you. That makes sense. Sounds like I should probably give up then! Perhaps the plugin will be updated in the future.

25 Feb 2017, 3:42 PM
#8
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Problem adding products to cart from product listing page

teaj:

Thank you. That makes sense. Sounds like I should probably give up then! Perhaps the plugin will be updated in the future.
I've seen solutions in the forum to address returning to the product listing page instead of the product info page for situations like this unrelated to the particular plugin. That said, the maintainer (and others interested) are less likely to know about this desired feature than if this were all discussed/related back to the plugin's thread.

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

25 Feb 2017, 3:58 PM
#9
teaj avatar

teaj

New Zenner

Join Date:
Dec 2007
Location:
South, UK
Posts:
66
Plugin Contributions:
0

Re: Problem adding products to cart from product listing page

Thanks, I will have a look for similar solutions then, hopefully I can work something out...

I couldn't find a 'Attributes on Product Listing' support thread, sorry, maybe I've missed it? It wasn't linked on the plugin page at least.

25 Feb 2017, 4:03 PM
#10
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Problem adding products to cart from product listing page

teaj:

Thanks, I will have a look for similar solutions then, hopefully I can work something out...

I couldn't find a 'Attributes on Product Listing' support thread, sorry, maybe I've missed it? It wasn't linked on the plugin page at least.

Were you trying this plugin or the older 1.3.9 "version"? https://www.zen-cart.com/downloads.php?do=file&id=2092

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

25 Feb 2017, 6:18 PM
#12
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Problem adding products to cart from product listing page

teaj:

It's the older version - https://www.zen-cart.com/downloads.php?do=file&id=1637

The one you linked to is for products with a single default attribute only, not attribute options.

Does appear to be a shame that there are no other threads from the original author of the older version that directly/easily relate to the older plugin... I'm thinking though that perhaps there is a little of both plugins that can be put together to get the expected/desired state/system response... Don't know, haven't used either, just seems like they both offer a piece of what is desired/needed, one to get the options displayed, the other to handle downstream processing possibly... shrug

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

25 Feb 2017, 6:29 PM
#13
teaj avatar

teaj

New Zenner

Join Date:
Dec 2007
Location:
South, UK
Posts:
66
Plugin Contributions:
0

Re: Problem adding products to cart from product listing page

Good thinking! Thanks, will report back if I can work something out. Cheers

25 Feb 2017, 7:11 PM
#14
teaj avatar

teaj

New Zenner

Join Date:
Dec 2007
Location:
South, UK
Posts:
66
Plugin Contributions:
0

Re: Problem adding products to cart from product listing page

I seem to have achieved the function I'm looking for, thanks to this post here.

I changed this part:

zen_href_link(zen_get_info_page($listing->fields['products_id']), zen_get_all_get_params(array('action')) .

to

zen_href_link(FILENAME_DEFAULT, zen_get_all_get_params(array('action')) .

in modules/product_listing.php

...and it appears to be working now! From search results you are taken to the home page rather than back to the search results, but at least the Product Listing page seems to be ok :)

Now I just need to work out how to make the 'Product added to cart' success message appear underneath the product that was added to cart... :blink: hopefully that should be possible?

Thanks

25 Feb 2017, 7:21 PM
#15
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: Problem adding products to cart from product listing page

There is the AJAX Add to Cart module for Zen Cart v1.5.3 that might do what you want, or help you get there. :smile:

The learning is in the doing.

Potent Products

25 Feb 2017, 9:52 PM
#16
teaj avatar

teaj

New Zenner

Join Date:
Dec 2007
Location:
South, UK
Posts:
66
Plugin Contributions:
0

Re: Problem adding products to cart from product listing page

Thanks, I do have that installed and working on the Product Info page, just not sure how to use it on the Product Listing pages. Will keep looking into it, hopefully will work it out! Cheers