我期待創造一個新的獎勵積分貨幣,所以我想要它顯示300獎勵積分,而不是我的Magento商店銷售價值300美元的產品。如何在Magento或Zend中創建自定義貨幣類型?
我已經加入這在LIB貨幣節嘗試了不好的做法,解決方案/的Zend /區域設置/數據/ en.xml
<currency type="RWP">
<displayName>Reward Point</displayName>
<displayName count="one">Reward Point</displayName>
<displayName count="other">Reward Points</displayName>
<symbol>Reward Points</symbol>
</currency>
我能夠啓用和使用在Magento下面這個線程: http://www.magentocommerce.com/boards/viewthread/56508/ 但它仍然使用默認的格式設置模式:¤ #,##0.00
所以它看起來像獎勵Points800.00
我的區域設置爲en_CA,據我所知,沒有辦法改變格式化格式,同時不影響CDN和USD格式。
我試着覆蓋Mage_Core_Model_Store,這樣如果當前的貨幣代碼是RWP,它將使用一組格式化選項格式化價格,但是當我處於產品視圖時,這不起作用。更何況,這似乎是一個非常骯髒的方式來完成我想要的。
/**
* Format price with currency filter (taking rate into consideration)
*
* @param double $price
* @param bool $includeContainer
* @return string
*/
public function formatPrice($price, $includeContainer = true)
{
if ($this->getCurrentCurrency()) {
/**
* Options array
*
* The following options are available
* 'position' => Position for the currency sign
* 'script' => Script for the output
* 'format' => Locale for numeric output
* 'display' => Currency detail to show
* 'precision' => Precision for the currency
* 'name' => Name for this currency
* 'currency' => 3 lettered international abbreviation
* 'symbol' => Currency symbol
*/
$options = array();
if ($this->getCurrentCurrencyCode() == 'RWP') {
$options = array(
'position' => 16,
'precision' => 0,
'format'=> '#,##0.00 '
);
}
return $this->getCurrentCurrency()->format($price, $options, $includeContainer);
}
return $price;
}
你有沒有遇到過這種情況?我正在Magento 2中做同樣的事情,並且增加一個新貨幣似乎是一項不重要的任務。 – floorz
是的,我相信我做到了,但那是6年前的事情,我幾乎沒有碰過PHP,更不用說Magento的時間差不多了。對不起:( –