1

How can I remove the leading '+' sign from prices of bundled product components? I have tried changing the $sign = ''; // Originally was $sign = '+'; and also $priceStr = ''; // Originally was $priceStr = $sign; in app/code/local/Mage/Catalog/Block/Product/View/Options/Abstract.php, without luck.

Is this achievable?

2

The responsible code is in Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option:

getSelectionQtyTitlePrice()

    $priceTitle .= ' &nbsp; ' . ($includeContainer ? '<span class="price-notice">' : '')
        . '+' . $this->formatPriceString($price, $includeContainer)
        . ($includeContainer ? '</span>' : '');

and getSelectionTitlePrice()

    $priceTitle .= ' &nbsp; ' . ($includeContainer ? '<span class="price-notice">' : '')
        . '+' . $this->formatPriceString($price, $includeContainer)
        . ($includeContainer ? '</span>' : '');

You can extend the class, override these methods and remove the plus sign. Then you need to rewrite all its child classes:

<config>
    <global>
        <blocks>
            <bundle>
                <rewrite>
                    <catalog_product_view_type_bundle_option>Your_Module_Block_Catalog_Product_View_Type_Bundle_Option</catalog_product_view_type_bundle_option>
                    <catalog_product_view_type_bundle_option_checkbox>Your_Module_Block_Catalog_Product_View_Type_Bundle_Option_Checkbox</catalog_product_view_type_bundle_option_checkbox>
                    <catalog_product_view_type_bundle_option_multi>Your_Module_Block_Catalog_Product_View_Type_Bundle_Option_Multi</catalog_product_view_type_bundle_option_multi>
                    <catalog_product_view_type_bundle_option_radio>Your_Module_Block_Catalog_Product_View_Type_Bundle_Option_Radio</catalog_product_view_type_bundle_option_radio>
                    <catalog_product_view_type_bundle_option_select>Your_Module_Block_Catalog_Product_View_Type_Bundle_Option_Select</catalog_product_view_type_bundle_option_select>
                </rewrite>
            </bundle>
    ...

These rewritten classes are copies of their originals (there is not much individual code, just the templates being defined) and must extend your class from above instead of the original Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option

| improve this answer | |
  • thank your for the reply. That does the job. My question is, If by changing '+' to ' ', you solve the problem, why would you extend the class? And excuse my ignorance, what is extending the class? – user2774042 Aug 11 '15 at 15:47
  • Of course, I have created an override of Option.php and applied the changes mentioned above in getSelectionQtyTitlePrice() and getSelectionTitlePrice() here: app/code/local/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php. – user2774042 Aug 11 '15 at 16:12
  • I always prefer a solution without changing core code or overriding it in the local code pool. With a custom module and class rewrites you only need to change the methods that you need to change which is easier to understand and more upgrade safe. – Fabian Schmengler Aug 11 '15 at 16:37
  • 1
    But I figured that if you prefer quick and easy code pool overrides, my answer would provide you with everything you need. Looks like I was right ;) – Fabian Schmengler Aug 11 '15 at 16:38

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.