I have my own custom block which extends "Mage_Catalog_Block_Product_View_Options_Type_Select" core block.

With in one of its function I'm using the following code to get priceStr with currency symbol.

$priceStr = $this->_formatPrice(array(
                'is_percent'    => ($_value->getPriceType() == 'percent'),
                'pricing_value' => $_value->getPrice(($_value->getPriceType() == 'percent'))

Every thing is working perfect except when the price is 0.0000 it returns "" (empty)

I would like it to return $0.00 when the price is 0


You'll need to extend the abstract class of Mage_Catalog_Block_Product_View_Options_Abstract

Highlighted is the issue, as if price formatting value is 0, a return of "" condition is met.

If you are already extending getValuesHtml in Type/Select you should be able to simply redefine your own method in your same class, since it is extending the Abstract class needed.

 * Return formated price
 * @param array $value
 * @return string
protected function _formatPrice($value, $flag=true)
    //if ($value['pricing_value'] == 0) {
    //    return '';

    $taxHelper = Mage::helper('tax');
    $store = $this->getProduct()->getStore();

    $sign = '+';
    if ($value['pricing_value'] < 0) {
        $sign = '-';
        $value['pricing_value'] = 0 - $value['pricing_value'];

    $priceStr = $sign;
    $_priceInclTax = $this->getPrice($value['pricing_value'], true);
    $_priceExclTax = $this->getPrice($value['pricing_value']);
    if ($taxHelper->displayPriceIncludingTax()) {
        $priceStr .= $this->helper('core')->currencyByStore($_priceInclTax, $store, true, $flag);
    } elseif ($taxHelper->displayPriceExcludingTax()) {
        $priceStr .= $this->helper('core')->currencyByStore($_priceExclTax, $store, true, $flag);
    } elseif ($taxHelper->displayBothPrices()) {
        $priceStr .= $this->helper('core')->currencyByStore($_priceExclTax, $store, true, $flag);
        if ($_priceInclTax != $_priceExclTax) {
            $priceStr .= ' ('.$sign.$this->helper('core')
                ->currencyByStore($_priceInclTax, $store, true, $flag).' '.$this->__('Incl. Tax').')';

    if ($flag) {
        $priceStr = '<span class="price-notice">'.$priceStr.'</span>';

    return $priceStr;

Be sure and use the codebase version you are using, as the above is CE 1.9 and may differ, also there is most likely a reason why a check of a 0 value occurs as other methods below the line may fail. Code above is untested.

A Stackoverflow question that may help:

| improve this answer | |
  • 1
    I have noticed the same and thank you for this. – Dharam Oct 27 '14 at 7:23

I use the Magento helper function to format price and when the field is empty it appears like €0,00.

Mage::helper('core')->currency($_product->getFullPrice(), true, false);

| improve this answer | |

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.