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?

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

1 Answer 1

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);
1
  • You can also use Mage::helper('core')->formatCurrency($_finalPrice, false); Nov 2, 2017 at 23:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.