我有一個名爲'ship_cost'的輸入類型爲'text field'的自定義產品屬性,而在後端添加值時會自動添加四小數點後加零。 我想'Rs這個價格。 45.00'格式,但目前它顯示爲'Rs。 45.0000' 。從magento中的自定義屬性「ship_cost」中刪除額外的零1.9.2.3
我很長時間沒有與megento合作過,基本上我是新手,如果有人知道如何解決這個問題,請提出適當的解決方案。
在此先感謝
拉利特
我有一個名爲'ship_cost'的輸入類型爲'text field'的自定義產品屬性,而在後端添加值時會自動添加四小數點後加零。 我想'Rs這個價格。 45.00'格式,但目前它顯示爲'Rs。 45.0000' 。從magento中的自定義屬性「ship_cost」中刪除額外的零1.9.2.3
我很長時間沒有與megento合作過,基本上我是新手,如果有人知道如何解決這個問題,請提出適當的解決方案。
在此先感謝
拉利特
有幾個方法可以做到這一點。
一個簡單的解決將是隻使用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);
這是一個核心magento方法,而大衛威爾金森的答案是直的php。 –