2

I have created a block of code that will show a row of products if the user doesn't hit the free delivery limit. My only problem is the way the price is being displayed. it shows it like £34.9900 instead of just £39.99 like it does on every other page.

This is my line of code that shows the price

<p class="upsell_pro_price"><?php echo $_product->getPrice();?></a></p>

If you know why this is doing this and can help would be much appreciated.

Thank you

Adam Allen
  • 2,205
  • 7
  • 37
  • 68

2 Answers2

5

You can use PHP to format your price. you can use the code like

number_format($_product->getPrice(), 2, '.', '')

It will display price upto 2 digits.

[Edit]

I think using Magento Format price functionality will be better option. I answered it in a hurry over viewing the top level problem of number formatting.

You should use instead

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

Dexter
  • 3,613
  • 4
  • 29
  • 61
5

You should use the Magento Price format helper which formats the price according to the store configuration:

Mage::helper('core')->formatPrice($_product->getPrice());
Thorsten
  • 483
  • 3
  • 10