Dali
Dali

Reputation: 7882

Format price in the current locale and currency

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?

Upvotes: 46

Views: 127576

Answers (7)

Neeraj Sharma
Neeraj Sharma

Reputation: 346

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

$formattedPrice = Mage::helper('core')->currency($finalPrice, true, false);

Upvotes: -3

Shadoweb
Shadoweb

Reputation: 6306

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

Mage::app()->getLocale()->currency('EUR')->toCurrency($price);

Upvotes: 18

Max Popoff
Max Popoff

Reputation: 109

Unformatted and formatted:

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

Or use:

Mage::helper('core')->formatPrice($price, true);

Upvotes: 4

Xman Classical
Xman Classical

Reputation: 5406

By this code for formating price in product list

echo Mage::helper('core')->currency($_product->getPrice());

Upvotes: 12

Simon
Simon

Reputation: 4193

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);

Upvotes: 131

Silas Palmer
Silas Palmer

Reputation: 421

$formattedPrice = Mage::helper('core')->currency($_finalPrice,true,false);

Upvotes: 29

hex4
hex4

Reputation: 695

try this:

<?php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); ?>

Upvotes: 3

Related Questions