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

DizzyMissLizzy’s picture

Any update on this?

Formatix Labs’s picture

I found solution ..
Line 326 of basic_cart.module:

// change from 
      $element[] = drupal_get_form('basic_cart_add_to_cart_quantity_form', $entity->nid);
// to
      $element[] = drupal_get_form('basic_cart_add_to_cart_quantity_form_' . $entity->nid, $entity->nid);

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.

function basic_cart_forms($form_id) {
  if (strpos($form_id, 'basic_cart_add_to_cart_quantity_form') !== FALSE) {
    $forms[$form_id]['callback'] = 'basic_cart_add_to_cart_quantity_form';
    return $forms;
  }
}  

Clear cache before test.

DizzyMissLizzy’s picture

Works perfect now, thank you!

elbeo’s picture

I can confirm that #2 works.

danSamara’s picture

I Confirm #2 too.

surendrasingh1’s picture

#2 working fine.. Thanks..

hitesh.koli’s picture

#2 working for me. Thanks !

Pierre Maciel’s picture

Just 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.

apaderno’s picture

Version: 7.x-3.0 » 7.x-3.x-dev
Issue tags: -add to cart, -quantity, -form issue