2016-05-12 52 views
0

我有一个名为'ship_cost'的输入类型为'text field'的自定义产品属性,而在后端添加值时会自动添加四小数点后加零。 我想'Rs这个价格。 45.00'格式,但目前它显示为'Rs。 45.0000' 。从magento中的自定义属性“ship_cost”中删除额外的零1.9.2.3

我很长时间没有与megento合作过,基本上我是新手,如果有人知道如何解决这个问题,请提出适当的解决方案。

在此先感谢

拉利特

回答

0

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

一个简单的解决将是只使用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; 
?> 
0

这将这样的伎俩。

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

这是一个核心magento方法,而大卫威尔金森的答案是直的php。 –