Grouped Products with Individual “Add To Cart” Button (Magento)

Grouped Products with Individual “Add To Cart” Button (Magento)

August 30, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Grouped Products with Individual “Add To Cart” Button (Magento)

Grouped Products with Individual “Add To Cart” Button in Magento

As an experienced Magento developer, I understand your need to create grouped products with individual “Add to Cart” buttons for each option. This allows customers to add only the selected product variant directly to their cart without having to add the entire group.

The challenge you’re facing is that when you try to add the “Add to Cart” button behind every grouped option, it shows an error because the amount hasn’t been selected yet. The solution lies in setting a default amount for the grouped product and then adding the “Add to Cart” button to each product individually.

Let’s dive into the steps required to achieve this:

  1. Set Default Amount for Grouped Product

To set a default amount of 1 for your grouped product, you need to modify the catalog/product/view.phtml template file located in your Magento theme directory (usually at app/design/frontend/{package}/{theme}/template/catalog/product/). In this file, look for the line where the quantity input field is added. It should look something like this:

<input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $_product->getStockItem()->getQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />

You can simply replace <?php echo $_product->getStockItem()->getQty() * 1 ?> with a fixed value of 1 to set the default quantity:

<input type="text" name="qty" id="qty" maxlength="12" value="1" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />

Now, when customers view your grouped product, it will have a default quantity of 1 pre-selected.

  1. Add “Add to Cart” Button for Each Option

To add an individual “Add to Cart” button for each option within the grouped product, you need to modify the catalog/product/view/type/grouped.phtml template file located in the same theme directory as before. In this file, find the line where the quantity input field is added for each associated product. It should look something like this:

<input type="text" name="super_group[<?php echo $_item->getId() ?>]" maxlength="12" value="<?php echo $_item->getQty()*1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />

You can replace this line with the following code to add a button that will add only the selected option directly to the cart:

<button type="button" title="<?php echo $this->__('Add to Cart') ?>" onclick="setLocation('<?php echo Mage::getUrl('checkout/cart/add', array('product' => $_item->getId(), 'qty' => 1)) ?>')" class="addtocart" /></button>

This code uses the Mage::getUrl function to generate a URL that adds the selected product with a quantity of 1 directly to the cart. When clicked, it will redirect the customer to the checkout page.

  1. Update Grouped Product Options

Ensure that you have configured your grouped product options correctly in the Magento admin panel (Catalog -> Manage Products -> Select your product -> Associated Products tab). Each option should be associated with a separate simple product that has its own SKU, price, and other attributes.

Remember to clear your cache after making these changes for them to take effect. You can do this by navigating to System -> Cache Management in the Magento admin panel and choosing “Flush Magento Cache” or using the command php bin/magento cache:clean from your terminal if you’re running a newer version of Magento.

By following these steps, you should now have a properly configured grouped product with individual “Add to Cart” buttons for each option. This allows customers to add only their selected variant directly to the cart without having to navigate through the entire grouped product.

For more detailed information on Magento development and best practices, I recommend checking out our blog at https://laravelcompany.com/. We cover a wide range of topics related to e-commerce development, including Magento customization, performance optimization, and security enhancements.

If you have any further questions or need assistance with specific Magento features, please don’t hesitate to reach out. I’m always happy to provide guidance on Magento development to help you create the perfect online shopping experience for your customers.

Happy coding!

Checkout Catalog Themes Configuration

Our network