我期待创造一个新的奖励积分货币,所以我想要它显示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的时间差不多了。对不起:( –