且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何删除Magento-1价格的小数?

更新时间:2023-11-30 11:02:46

要更改magento中的价格精度,您需要覆盖一些核心文件.

In order to change price precision in magento you would need to overwrite some core files.

在下面的示例中,我们将精度更改为0.

In the example below we are changing precision to 0.

1):覆盖lib/Zend/Currency.php并更改精度:

1) Overwrite lib/Zend/Currency.php and change precision around line:

 69     protected $_options = array(
 70         'position'  => self::STANDARD,
 71         'script'    => null,
 72         'format'    => null,
 73         'display'   => self::NO_SYMBOL,
 74         'precision' => 0,    /*CHANGE*/
 75         'name'      => null,
 76         'currency'  => null,
 77         'symbol'    => null,
 78         'locale'    => null,
 79         'value'     => 0,
 80         'service'   => null,
 81         'tag'       => 'Zend_Locale'
 82     );

2)覆盖app/code/core/Mage/Core/Model/Store.php并更改roundPrice函数:

2) overwrite app/code/core/Mage/Core/Model/Store.php and change roundPrice function:

public function roundPrice($price)
{    
    return round($price, 4);
}

3)覆盖app/code/core/Mage/Directory/Model/Currency.php并更改格式功能:

3) overwrite app/code/core/Mage/Directory/Model/Currency.php and change format function:

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