Vote up!
Vote down!

Why does my Add to Cart Form in Views only ever add 1 of the product to the cart?

I have created a View that displays the Add to Cart form and exposes the quantity textfield with a default value of 1. No matter what I change the quantity to before submitting, the cart is only incremented by one. Any ideas how to make this work?

Asked by: ehalber
on March 22, 2013

1 Answer

Vote up!
Vote down!

I've done some recent testing on this in relation to this issue, and as far as I can see, the Views Add to Cart form itself works fine. If it's the only Add to Cart form on a page, I can add the expected number of product to the cart.

However, if you have the Views based Add to Cart form on a page that also displays the Add to Cart form in a product display for the same product (or else shows multiple versions of the form inside the same View), then you'll end up with duplicate form IDs / form data on the page. Drupal won't know how to distinguish between the multiple forms and is picking up the quantity from another form on the page with the same form ID.

There's a patch in the issue linked to mitigate the issue, but the immediate solution for anyone in this situation is to figure out why they have multiple Add to Cart forms on the same page and decide if there's a cleaner way to present the product page that avoids the duplication.

Ryan Szrama
Answer by: Ryan Szrama
Posted: Apr 1, 2013