I have different view blocks that display multiple products on the same page, each product has their own attributes such as product bundle and custom line item, these serves as an option set / criteria of the main product. The results of the options slider will be the value of the customs line item that is hidden.

What I plan to accomplish is to add all these selected products with the selected attributes on the cart at the same time with just one button.


Product 1:

enter image description here

Product 2:

enter image description here

These are the methods/modules I have tried:

The first two methods work for the main product only, no attributes of the customs line item and bundle products. I tried including the add to cart form in the view with the VBO or commerce product: quantity field of commerce add to cart extras but it doesn't work maybe because it's a form within a form.

Does anyone have any suggestion on how to make this work?

Thank you in advance!

1 Answer 1


I suggest writing a custom hook_submit() who will add all the items of your views to the shopping cart.

Something like that should do the job.

 global $user;

 $results = views_get_view_result('view_name', 'block_1');

 foreach($results as $item) {
 // Create new line item:
 $line_item = commerce_product_line_item_new($product, $quantity);

 // Add to current user's cart
 $line_item_added = commerce_cart_product_add($user->uid, $line_item);

Good luck.


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.