Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Probably due to the way the basic cart add to cart quantity form is called and because the forms get the same form id, add to cart forms send an incorrect item to the cart.
My case. Using a view to call fields from all my products, including the add to cart field. If I select add to cart quantity, any add to cart button I click sends the first item in the list (but with the correct quantity associated to the button I just pressed) to the cart.
Comments
Comment #1
DizzyMissLizzy CreditAttribution: DizzyMissLizzy commentedAny update on this?
Comment #2
Formatix Labs CreditAttribution: Formatix Labs commentedI found solution ..
Line 326 of basic_cart.module:
Now we have different form IDs. But, how to build different forms with single function? We should implement hook_form() function, where we check form id and return our builder function when form_id is our.
Clear cache before test.
Comment #3
DizzyMissLizzy CreditAttribution: DizzyMissLizzy commentedWorks perfect now, thank you!
Comment #4
elbeo CreditAttribution: elbeo commentedI can confirm that #2 works.
Comment #5
danSamara CreditAttribution: danSamara commentedI Confirm #2 too.
Comment #6
surendrasingh1 CreditAttribution: surendrasingh1 commented#2 working fine.. Thanks..
Comment #7
hitesh.koli#2 working for me. Thanks !
Comment #8
Pierre Maciel CreditAttribution: Pierre Maciel commentedJust to confirm #2 also works for me.
BUT, i'm facing problems to add to cart in a little bit more complex case.
1- My view is a Table
2- This table view is grouping results
3- This view uses 3 relationships (content type, author and user profile)
The add to cart with quantity does not work with some SORT Criteria options.
I am trying to use it with Global Random but no luck, it does work without sort criterias or with the default one...
Any ideas?
THank you guys very much.
Comment #9
apaderno