Multiple products and first display of cart

General ShopSite user discussion

Multiple products and first display of cart

Postby cshimei » Mon Nov 18, 2013 7:02 pm

I haven't located a solution for this in the forums or knowledge base, although maybe I am just not hitting the correct search terms.

Using Pro v11.

My product pages (there are only two) use the multiple product add-to-cart coding, based on the examples from the cookbook. Each page consists of 8 products, each with their own qty inputs, and each qty input is preset to 0.

When choosing quantities for one or more of the products -- but not all -- and then choosing "Add to cart", the items (with correct quantities) are added to the cart, and the cart is displayed.

Unfortunately, the cart also displays all of the products that were not selected; i.e., left at zero quantities. It shows the quantity for these items as 0, so I get a list of all 8 items "added" to the cart, some with valid quantities, the rest with 0 quantities.

Recalculating the cart clears the 0 quantity items. So does checking out.

It is a minor thing, but I'm glad I don't have 20 or 30 items on the page.

Is there a way to prevent this, or to force the recalc so the 0 quantity items are cleared?
cshimei
 
Posts: 4
Joined: Mon Nov 18, 2013 6:45 pm

Re: Multiple products and first display of cart

Postby Jim » Mon Nov 18, 2013 8:50 pm

There isn't any built in way to exclude all items from being added even if the quantity is 0. You could add some javascript to your page to check which products have a non-zero quantity and only submit those items. I'm not a javascript expert so don't know how to do it but it can be done.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: Multiple products and first display of cart

Postby robm » Tue Nov 19, 2013 7:50 am

We have a tutorial that includes JavaScript code to not add zero quantity products to the cart in a multi add to cart page. Reference:

http://support.lexiconn.com/news/viewtopic.php?t=326

Rob
robm
 
Posts: 463
Joined: Fri Aug 04, 2006 5:46 pm
Location: Connecticut

Re: Multiple products and first display of cart

Postby cshimei » Thu Nov 21, 2013 1:48 pm

Jim - Thank you for your suggestion to use Javascript -- I figured that was how it would have to be done.

Rob - Thank you for the solution/Javascript example you linked to. I've updated the templates with a slightly different version of this, and it works as advertised :)
cshimei
 
Posts: 4
Joined: Mon Nov 18, 2013 6:45 pm


Return to User Forum

Who is online

Users browsing this forum: No registered users and 122 guests