从自定义属性“”的值中删除多余的零;ship_cost”;在图1.9.2.3中


Remove extra zeros from value of custom attribute "ship_cost" in magento 1.9.2.3

我有一个名为"ship_cost"的自定义产品属性,输入类型为"text field"。当把一个值放在后端时,它会在小数点后自动添加四个额外的零。

我想要这个价格,卢比。45.00"格式,但目前显示为"Rs。45.0000'.

我已经很久没有和马根托合作了,基本上,我是一个新手。

有几种方法可以做到这一点。

一个简单的修复方法是只使用number_format()函数:

<?php 
    $_product = $this->getProduct();
    $prodShipCost = $_product->getData('ship_cost'); // Or however you want to get the attribute values
    $priceFormatted = number_format($prodShipCost, 2, '.', '');
    echo $priceFormatted;
?>

这样就可以了。

Mage::getModel('directory/currency')->format($_product->getData('ship_cost'), array('display'=>Zend_Currency::NO_SYMBOL), false);