开发者

How to change currency format in zend framework's locale settings (skipping decimal places)?

In it's default setup, the currency format for German Euro is "#,##0.00 ¤" which displays something like "750,00 €". I want to skip the decimal places to ha开发者_StackOverflowve the display "750€". When I change the currency format to "0 ¤" the €-symbol is not being displayed.

Is this a bug oder what am I doing wrong?


According to the documentation, you can call the Zend_Currency setFormat method, which accepts an array of parameters, one of which is 'precision'. Set the precision parameter to 0 and it shouldn't have any decimal places.

http://framework.zend.com/manual/en/zend.currency.options.html


Magento has hardcoded the decimal places to 2 in Mage_Directory_Model_Currency

public function format($price, $options=array(), $includeContainer = true, $addBrackets = false)
{
  return $this->formatPrecision($price, 2, $options, $includeContainer, $addBrackets);
}

So I just wrote a small module which makes the hardcoded 2 configurable in the backend.


In Zend, to custom the currency format, you could edit the locale setting file and remember to clean the cache (Ex: Zend Cache directory of Magento is /var/cache).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜