3

With VBO and Rules I can display a list of Commerce products with checkboxes and a button to add the checked products to the cart (see how).

Is there a way to integrate these checkboxes with the default Add-to-cart form from Commerce? I want to have a single Add-to-Cart form with one button, not two forms.

Alternatives I tried:

Is there another way/module?

My goal is to display optional add-on products (with checkboxes) on a primary product page. If the user doesn’t select any add-on product, only the primary product is added to the cart; if the user selects add-on products, the primary product and the selected add-on products get added to the cart.

(The question Drupal Commerce - optional extra products on add to cart form seems to have the same goal, but OP seems to be fine with the Commerce Product Add-on module if it would work for him in his case. The question add to cart - multiple products at once seems to be for adding always the full set of products, so without checkboxes.)

1 Answer 1

1

You could do it with Custom Line Item Fields for checkboxes and either just track the add on products using the line item or create a rule that adds the matching product to the cart when an line item is added that has checkbox field values.

PS: If you go with line item fields only approach, you should use pricing rules to change the final price of any line item with those check boxes to add prices to them. If you do that, then you might want this patch that allows line item fields to automatically ajax update the price when something changes:

https://www.drupal.org/node/1541886

ajax-powered price changes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.