46

I use :

$product->getPrice();

to get the unformatted price that I can calculate "quantity X price" with ajax.

I want to reformat the total in the current locale and currency. How can I do that?

scrowler
  • 24,273
  • 9
  • 60
  • 92
Bizboss
  • 7,792
  • 27
  • 109
  • 174

7 Answers7

131

I think Google could have answered your question ;-) See http://blog.chapagain.com.np/magento-format-price/.

You can do it with

$formattedPrice = Mage::helper('core')->currency($finalPrice, true, false);
Simon
  • 4,103
  • 7
  • 28
  • 53
  • 25
    Google answered mine... it brought me here! – Jongosi Feb 17 '15 at 11:56
  • 4
    Careful guys, the currency method not only formats but also converts in the store's currency. If you want formatting but no conversion, then go for Mage::helper('core')->formatPrice($price). See method signature for info on the second parameter. – Martin Rasser Jul 18 '16 at 12:07
29
$formattedPrice = Mage::helper('core')->currency($_finalPrice,true,false);
Silas Palmer
  • 421
  • 4
  • 3
18

For formatting the price in another currency than the current one:

Mage::app()->getLocale()->currency('EUR')->toCurrency($price);
Shadoweb
  • 5,812
  • 1
  • 42
  • 55
12

By this code for formating price in product list

echo Mage::helper('core')->currency($_product->getPrice());
Xman Classical
  • 5,179
  • 1
  • 26
  • 26
4

Unformatted and formatted:

$price = $product->getPrice();
$formatted = Mage::helper('core')->currency($price, true, false);

Or use:

Mage::helper('core')->formatPrice($price, true);
Max Popoff
  • 111
  • 1
  • 5
3

try this:

<?php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); ?>
hex4
  • 695
  • 2
  • 9
  • 23
-3

This is a charming answer. Work well on any currency which is selected for store.

$formattedPrice = Mage::helper('core')->currency($finalPrice, true, false);
Keyur Shah
  • 11,043
  • 4
  • 29
  • 48
Neeraj Sharma
  • 346
  • 1
  • 4
  • 16