I know there are already a lot of answers for how to add multiple products at once. I don't think this is a duplicate because here we are talking about subproducts not products.

Currently on my catalog product view there are 4 radio buttons so that the customer can select 4 different variations of the product. If the customer selects variation #1 and clicks add to cart, then there will be 1 item in the cart. If they go back to the catalog product view and select variation #2 and click add to cart, then there will be two separate items in the cart. So these two variations are essentially two different "products" because they have different "subtitles", different prices and they have their own row on the cart view.

The 4 radio buttons are all part of the same radio button group, thus the customer can only add a single variation to the cart at a time. If they want to add another variation to the cart they must go back to the product page and click add to cart again.

We want to break the radio buttons up into two groups of 2 so that the customer can select 2 variations at once and then click add to cart in order to add the 2 variations to the cart at the same time.

The issue that I am having is that I can't figure out how to alter CartController::addAction so that it will add 2 product variations to the cart at the same time.

The only difference in terms of the $params from one variation to another is the value for $params['super_attribute']['my_val']. If I hardcode this value into addAction() then I can control which variation gets added to the cart - so I know that's what controls the variation.

As a test I thought I would be able to change this:

$cart->addProduct($product, $params);

to this:

$params['super_attribute']['my_val'] = 1;
$cart->addProduct($product, $params);

$params['super_attribute']['my_val'] = 2;
$cart->addProduct($product, $params);

but what ends up happening with that approach is that the first one gets added twice(ie. it's the only one in the cart with a quantity of 2). I've tried several other variations of this test code but nothing works.

Is there a way to do this in CartController::addAction(or some of the PHP it calls)? Or should I try a different way(like maybe make an AJAX call to the API)?

  • Please check below product configuration method. Oct 22, 2018 at 7:00

1 Answer 1


You can go with custom option checkbox or multi-select. I have tried to same way, It's working. Please check below.

  1. Create a product with custom options input type checkbox.

enter image description here

  1. If you need to set main product price 0 (optional).

enter image description here

  1. Product shows in front-end.

enter image description here

  1. Multiple sub products added in cart.

enter image description here

  • Thank you for responding but that's not it. There needs to be two radio button groups on the product page instead of checkboxes. And on the cart page there needs to be separate rows(ie. a separate price, quantity, etc.) for each radio button group that has a selection.
    – Ryan
    Oct 22, 2018 at 10:04

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.