Add bundle product to cart without having to specify the options

New Wave New Thinking

My project needed to only show a single line for a bundle product, hidden options default selected and purchased when buying the bundle. The product had be buyable from the category view.

Bundle config:

  • Bundle with dynamic price
  • Options are configured to be required, default values and radio buttons default selected values

I went into my custom category view template and added the following:

<form action=”<?php echo Mage::$this->helper(‘checkout/cart’)->getAddUrl($product); ?>” method=”post” id=”product_addtocart_form_<?php echo $product->getId()?>”>


// If we have a bundle:

if ($_product->getTypeId() == ‘bundle’){

$selectionCollection = $_product->getTypeInstance(true)->getSelectionsCollection(

$_product->getTypeInstance(true)->getOptionsIds($_product), $_product


foreach($selectionCollection as $option) {

echo ‘<input type=”hidden” name=”bundle_option[‘ . $option->option_id  . ‘]” value=”‘ .  $option->selection_id . ‘” />’;

echo ‘<input type=”hidden” name=”bundle_option_qty[‘ . $option->option_id . ‘]” value=”1″ />’;

}//end: foreach $selectionCollection

} // end: if $_product == bundle


<input type=”text” name=”qty” maxlength=”4″ value=”1″ />

<button type=”button” onclick=”this.form.submit()” />


The above creates a add-to-cart-form, retrieves the bundle sub-products if…

View original post 9 more words


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s