emediastudios Posted October 30, 2012 Share Posted October 30, 2012 Hi all, I have building a custom template for a client and have a problem where the price is displaying in the format $19.9500 The code i am using to call the price is: <?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getPrice(), 'price') ?> Quote Link to comment Share on other sites More sharing options...
sumpygump Posted October 30, 2012 Share Posted October 30, 2012 You can use PHP's round() function. Example: $price = 19.9500; echo round($price, 2); So, in your case: <?php echo $this->helper('catalog/output')->productAttribute($_product, round($_product->getPrice(), 2), 'price') ?> Quote Link to comment Share on other sites More sharing options...
emediastudios Posted October 30, 2012 Author Share Posted October 30, 2012 You can use PHP's round() function. Example: $price = 19.9500; echo round($price, 2); So, in your case: <?php echo $this->helper('catalog/output')->productAttribute($_product, round($_product->getPrice(), 2), 'price') ?> Love your work sumpygump, have been on the magento forum and have had no help. You solved my problem, works a charm! awesome! thankyou! Quote Link to comment Share on other sites More sharing options...
Christian F. Posted October 30, 2012 Share Posted October 30, 2012 An even better choice would be number_format (), as you can do more than just define the number of decimal places with it. Quote Link to comment Share on other sites More sharing options...
reifoss Posted September 10, 2015 Share Posted September 10, 2015 (edited) There is an official Magento Way that also adds the proper currency symbol for internationalization and a <span class="price"> Mage::helper('core')->currency($rate->getPrice()); Sorry for gravedigging but this is one of the highest google results for the topic. Edited September 10, 2015 by reifoss Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.