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....
Code:
$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...
HTML Code:
<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...-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:
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?
Re: Problem adding products to cart from product listing page
Yes it was recently added, to a fresh v155 install.
Thanks
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!
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
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.
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.
Re: Problem adding products to cart from product listing page
Quote:
Originally Posted by
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.
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.
Re: Problem adding products to cart from product listing page
Quote:
Originally Posted by
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
Re: Problem adding products to cart from product listing page
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.
Re: Problem adding products to cart from product listing page
Quote:
Originally Posted by
teaj
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*
Re: Problem adding products to cart from product listing page
Good thinking! Thanks, will report back if I can work something out. Cheers
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
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:
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