Magento价格格式-2或3个小数位 [英] Magento Price Formatting - 2 or 3 decimal places

查看:43
本文介绍了Magento价格格式-2或3个小数位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要求将某些商品的价格设置为小数点后3位.我已经通过将'precision'变量更改为3来实现这一点,但是这意味着网站上的每个价格都显示为小数点后3位(即:空购物车显示为0.000英镑).我只想显示小数点后第三位,但是我不确定在代码库中哪里可以找到.有人可以指出我正确的方向吗?

I have a requirement to set prices on certain items to 3 decimal places. I have achieved this by changing the 'precision' variable to 3, however this now means that every price on the site is displayed to 3 decimal places (ie: an empty shopping cart shows as £0.000). I want to only show the 3rd decimal place if it's required but I'm not sure where to find this in the code base. Can anyone point me in the right direction please?

推荐答案

尝试使用此功能

echo number_format($product->getPrice(), '2', '.', ',')

echo number_format($product->getPrice(), '3', '.', ',')

这篇关于Magento价格格式-2或3个小数位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆