如何在magento中获取自定义价格格式(使用3 Precision) [英] How to get custom price format (with 3 Precision) in magento

查看:80
本文介绍了如何在magento中获取自定义价格格式(使用3 Precision)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望有人可以提供帮助.

hope someone can help.

需要数字格式对此显示3个小数....(精确地为2)

Need number_format to show 3 decimal on this.... (actualy 2)

<?php echo $this->helper('checkout')->formatPrice($_item->getCalculationPrice()/$_product->getAnzeigeMenge()) ?>

总是使用number_format($ _ value,3,,",."),但不知道如何使它工作.

alway used number_format($_value, 3,",",".") but dont know how to get this to work.

推荐答案

[magento]\app\code\core\Mage\Checkout\Helper\Data.php

添加以下功能

public function customformatPrice($price)
{
        return $this->getQuote()->getStore()->customformatPrice($price);
}

在[magento] \ app \ code \ core \ Mage \ Core \ Model \ Store.php中添加以下功能

public function customformatPrice($price, $includeContainer = true)
   {
          if ($this->getCurrentCurrency()) {
          //sets the floating point precision to 3 points

          return $this->getCurrentCurrency()->format($price, array('precision'=>3),     $includeContainer);

         }  
         return $price;
   }

您可以像上面一样使用

//magento default call
echo Mage::helper('checkout')->formatPrice(3000.1231);//Rs3,000.12
echo "<br>";
//customized function call
echo Mage::helper('checkout')->customformatPrice(3000.12313);//Rs3,000.123

实际上,您可以直接在[magento] \ app \ code \ core \ Mage \ Core \ Model \ Store.php中修改 formatPrice(),但由于您希望同时使用这两种格式,因此我们创建了自定义函数

actually you can direct modify the formatPrice() in [magento]\app\code\core\Mage\Core\Model\Store.php but as you want both format we create custom function

希望这对您有帮助

这篇关于如何在magento中获取自定义价格格式(使用3 Precision)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆