I want to remove/modify the string that I get in the cart view inside the table (s. picture)

In my shop it says "1 x optionname €10.00" for example. I want to delete the "1 x" I also recognized, that if there are two options selected the output is one string separated by <br/> tag. Is there also a way to get the options as single strings, so that I maybe could add a "+"?

I'm trying stuff within default.phtml and looked into Default.php but I'm not fit enough with php to understand what is done there.

enter image description here


Bundles are challenging. Very challenging. Some rumaging around in the code exposes:

file: app/code/core/Mage/Bundle/Helper/Catalog/Product/Configuration.php
class: Mage_Bundle_Helper_Catalog_Product_Configuration
function: getBundleOptions()
    public function getBundleOptions(Mage_Catalog_Model_Product_Configuration_Item_Interface $item)
        $options = array();
                    foreach ($bundleSelections as $bundleSelection) {
                        $qty = $this->getSelectionQty($product, $bundleSelection->getSelectionId()) * 1;
                        if ($qty) {
                            $option['value'][] = $qty . ' x ' . $this->escapeHtml($bundleSelection->getName())
                                . ' ' . Mage::helper('core')->currency(
                                    $this->getSelectionFinalPrice($item, $bundleSelection)

This is called via

file:  app/code/core/Mage/Bundle/Block/Checkout/Cart/Item/Renderer.php
class: Mage_Bundle_Block_Checkout_Cart_Item_Renderer
function:  getOptionList()
    public function getOptionList()
        return Mage::helper('bundle/catalog_product_configuration')->getOptions($this->getItem());

//AND via:
//Mage_Bundle_Block_Checkout_Cart_Item_Renderer getOptions(
//Mage_Bundle_Block_Checkout_Cart_Item_Renderer getOptionList()
//default.phtml : <?php if ($_options = $this->getOptionList()):?>

But it isn't obvious. I think $this in default.phtml is Mage_Bundle_Block_Checkout_Cart_Item_Renderer due to:

    //file: app/design/frontend/base/default/layout/bundle.xml
            <reference name="checkout.cart">
                <action method="addItemRender"><type>bundle</type><block>bundle/checkout_cart_item_renderer</block><template>checkout/cart/item/default.phtml</template></action>

So, how to get what you want? You could write your own item renderer and use XML in local.xml to point to Magento to that. You could extend the class and write your own 'getBundleOptions()' function. That would be the formal way. One shortcut is to copy the file




and edit that file, with the risk of future problems when you upgrade Magento because your local file will always be called, never the new version. Maybe that is okay as long as you and future developers are aware of it. I can tell you that file does change in 1.8.0 but at first glance the changes are superfluous.

Anyway, I often look at these things and say life is too short. Why not modify the .phtml file a little bit?

[At this point I have to ask about your note above that each option value ends with <br /> I think that is due to a custom theme which is but I don't know where your <br /> is coming from.]

Turning to the default.phtml file 'default.phtml', we might just apply some string manipulation if the product type is bundle: (code not tested, just written here)

file: app/design/frontend/yourtheme/default/template/checkout/cart/item/default.phtml

//find this bit of code (it is at the end of a longer line)
//<?php echo $_formatedOptionValue['value'] ?>
//change it as you see fit, for example

                if ($_item->getProduct()->getType()=='bundle'){
                     //manipulate the string:
                  $myOriginalOptionValue = $_formatedOptionValue['value'];
                  $myPreferredOptionValue = preg_replace("#^[0-9]+\sx\s#","",$myOriginalOptionValue);
                  echo $myPreferredOptionValue;
                  //carry on as before
                  echo $_formatedOptionValue['value'];


I hope it works out for you. Customising bundle display code is difficult because the blocks are deeply nested.

  • I will try this, when I find the time. Thanks Apr 27 '14 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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