2

I've been looking through guides and other questions, but I simply can't get the finalPrice formatted as I want. I would like to display the price with the chosen currency first and then the price with two decimals, e.g. as;

$4.00

Im retreiving the price with the following line;

echo $product->getFinalPrice();

This simply displays on the front-end as;

4

I've also tried using the following line;

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

This gives me the right formatting, but doesn't retreive the actual price of the product. It display as;

€0.00

The one gets the actual price and the other formats it the way I want, so I guess I have to combine these in some way?

McKeene
  • 501
  • 2
  • 9
  • 25
  • 6
    have you tried echo $formattedPrice = Mage::helper('core')->currency($product->getFinalPrice(), true, false); – Marius Aug 12 '14 at 09:32

1 Answers1

7

This line is the correct answer:

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

However, you're getting a value of €0.00 because the $finalPrice variable isn't set to anything. This should resolve that issue:

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

Or, you can combine both into a single line, like @Marius suggested:

echo $formattedPrice = Mage::helper('core')->currency($product->getFinalPrice(), true, false);
Colin O'Dell
  • 1,215
  • 1
  • 7
  • 23