Remove Magento pricing for options in dropdown on both simple and configurable products

22.Sep.2014

Sometimes we and/or our customers want to remove price changes from product options and have them display only on change on our price label in Magento.

For configurable products, prices are added to label from js module Product.Config. To remove them, we have to rewrite module’s function getOptionLabel. We need a new javascript file, inside js folder, with following code:

1
2
3
Product.Config.prototype.getOptionLabel = function(option, price) {
    return option.label;
};

Of course, to make it work, we need to add newly created script to single product view page. This can be done by adding following line to the catalog.xml, after varien/configurable.js has been added.

<action method="addJs"><script>path/to/our/file.js</script></action>

To remove the price from single product’s custom options, we need to (due to lack of better solution), rewrite core block responsible for rendering product options input elements.

After rewriting Mage_Catalog_Block_Product_View_Options_Type_Select block, we have to change the way options are rendered. Around line 65, there is a loop similar to the following code:

1
2
3
4
5
6
7
8
9
10
11
foreach ($_option->getValues() as $_value) {
    $priceStr = $this->_formatPrice(array(
        'is_percent'    => ($_value->getPriceType() == 'percent'),
        'pricing_value' => $_value->getPrice(($_value->getPriceType() == 'percent'))
    ), false);
    $select->addOption(
        $_value->getOptionTypeId(),
        $_value->getTitle() . ' ' . $priceStr . '',
        array('price' => $this->helper('core')->currencyByStore($_value->getPrice(true), $store, false))
    );
}

In our own file which we used for rewriting Magento’s default code, we should use the following version:

1
2
3
4
5
6
7
foreach ($_option->getValues() as $_value) {
    $select->addOption(
        $_value->getOptionTypeId(),
        $_value->getTitle(),
        array('price' => $this->helper('core')->currencyByStore($_value->getPrice(true), $store, false))
    );
}

With these simple changes we will be able to remove ugly formatted pricing in dropdown in our Magento’s single product view pages.