关于这个问题,shivam会员帮我解决了一个自定义价格格式的问题…
如何在magento中获得自定义价格格式(具有3精度)
这里我现在使用精度3
public function customformatPrice($price, $includeContainer = true)
{
if ($this->getCurrentCurrency()) {
//sets the floating point precision to 4 points
return $this->getCurrentCurrency()->format($price, array('precision'=>3), $includeContainer);
}
return $price;
}
但我使用了四舍五入精度为4
public function roundPrice($price,$roundTo=4)
{
return round($price, $roundTo);
}
当我使用后端输入价格如9.2400欧元时,所有工作都很好,然后前端的输出很好。但是当我在后端输入9.2450€时,前端的输出是圆形的。我似乎漏掉了一个正确的整价方法。
这个代码用于列表视图…(圆形显示错误):
<?php echo ''.Mage::helper('checkout')->customformatPrice($_minimalPriceDisplayValue /1.19 /$_bbase_qty, false) ?>
此代码用于产品视图。(完美四舍五入)但它不能在列表或价格php中使用此代码。
<span class="price"><?php echo ''.Mage::helper('checkout')->customformatPrice(min($product_price)*1.19/($_bbase_qty),true,false); ?></span>``
希望有人能帮助我弄清楚在哪里是问题的四舍五入或可以帮助我如何使用最后的代码直接在list. php。
谢谢你的帮助
打开文件[magento]appcodecoreMageCoreModelStore.php
public function roundPrice($price)
{
return round($price, 4);//change 2 to 4
}
public function customformatPrice($price, $includeContainer = true, $options=array())
{
if ($this->getCurrentCurrency()) {
return $this->getCurrentCurrency()->format($price,$options, $includeContainer);
}
return $price;
}
echo Mage::helper('checkout')->customformatPrice(3000.12313,true,array('precision'=>4));
希望这对你有帮助
注意:不要直接在核心文件中更改,而是覆盖它