Magento – Replace dot with comma in price

ce-1.9.3.1magento-1.9price

Does anyone know how to remove the space after the symbol in the price? It's defined in the price.phtml file but i can't find a way to remove the space…

I tried formatting the price and got this now:

<div class="price-box bc-deal-price">
    <?php
        $sym = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); 
        $price = $_product->getPrice();
        $specialprice = $_product->getFinalPrice();
        if($price != $specialprice){
           if($price != ''){
                echo '<p class="old-price"><span class="price-label">';
                echo $this->__('Regular Price'). ': </span>';
                echo '<span id="old-price" class="price">'.$sym.''.number_format($price,2).'</span></p>';
            }
            if($specialprice != '')
            {
                echo '<p class="special-price">
                    <span class="price-label">Special Price</span>
                    <span id="" class="price">'.$sym.''.number_format($specialprice,2).'</span>
                </p> ';
            } 
            }else {
                echo '<div class="price-box">
                        <span id="product-price-'.$_product->getId().'" class="regular-price">
                            <span class="price">'.$sym.''.number_format($price,2).'</span>                                    
                        </span>
                    </div>';    
        }
    ?>
</div>

But now it's display €99.95 instead of €99,95 with a comma, how can i change it to show a comma?

Best Answer

You can rewrite the method Mage_Directory_Model_Currency::formatTxt in one of your classes and make it look like this:

public function formatTxt($price, $options = array())
{
    $formatted = parent::formatTxt($price, $options);
    $noSpace = str_replace(' ', '', $formatted);
    return $noSpace;
}

In case you need it, here is an explanation on how to rewrite a model provided by Inchoo.

Related Topic