Manually Format Prices Using Number_Format

Thursday, 5. April 2012

If you have used round, floor etc while trying to format the prices display in Magento (or any other cart for that matter) but to undesired effect due to decimal points – a php number_format could be just the solution you are looking for!

It format the number nicely with ability to round and even change the decimal separator!

It also keeps the ending ‘0’ so you are sure your price display will be consistent across the pages.

Example:

number_format($_product->getPrice(),2); # 23.70

You can ready more Here

Leave a Reply

You must be logged in to post a comment.