我通过更改以下函数设法对总数进行了舍入: app \ code \ core \ Mage \ Sales \ Model \ Quote \ Address \ Total \ Grand.php public function collect(Mage_Sales_Model_Quote_Address $address) { $grandTotal = $address->getGrandTotal(); $baseGrandTotal = $address->getBaseGrandTotal(); $totals = array_sum($address->getAllTotalAmounts()); $baseTotals = array_sum($address->getAllBaseTotalAmounts()); $address->setGrandTotal(round(($grandTotal+$totals),2)); //Modificated $address->setBaseGrandTotal(round(($baseGrandTotal+$baseTotals),2)); //Modificated //$address->setGrandTotal($grandTotal+$totals); --Original //$address->setBaseGrandTotal($baseGrandTotal+$baseTotals); --Original return $this; } 是否可以同时对小计和税额进行四舍五入?我尝试在上述目录中的其他文件中执行此操作,但是没有结果.解决方案我知道这个问题比较老,但是最近我遇到了完全相同的问题.所以这是我的解决方案,到目前为止似乎还行得通.public function collect(Mage_Sales_Model_Quote_Address $address){ $grandTotal = round($address->getGrandTotal(), 2); $baseGrandTotal = round($address->getBaseGrandTotal(), 2); $subTotal = round($address->getSubtotal(), 2); $baseSubTotal = round($address->getBaseSubtotal(), 2); $taxAmount = round($address->getTaxAmount(), 2); $baseTaxAmount = round($address->getBaseTaxAmount(), 2); $shippingAmount = round($address->getShippingAmount(), 2); $baseShippingAmount = round($address->getBaseShippingAmount(), 2); $address->setSubtotal($subTotal); $address->setBaseSubtotal($baseSubTotal); $address->setTaxAmount($taxAmount); $address->setBaseTaxAmount($baseTaxAmount); $address->setShippingAmount($shippingAmount); $address->setBaseShippingAmount($baseShippingAmount); $address->setGrandTotal($grandTotal + $subTotal + $shippingAmount + $taxAmount); $address->setBaseGrandTotal($baseGrandTotal + $baseSubTotal + $baseShippingAmount + $baseTaxAmount); return $this;}I have installed the ET Currency Manager in order to sell products by gramm with prices < 0.01 per gramm.The problem is that this sometimes leads to subtotals, taxes and totals with half cents...which (apart from the paypal problem) is confusing for the customer and not acceptableTherefore I am searching for a solution to round the subtotal, tax and grand total value to 2 decimal places.I know that the ET Currency Manager has the option "exclude from checkout" but that leads to other problems wherefore it is not relevant for this question (if I do not get a solution here I will ask this question seperately)I managed to round the grand total by changing the following function:app\code\core\Mage\Sales\Model\Quote\Address\Total\Grand.phppublic function collect(Mage_Sales_Model_Quote_Address $address) { $grandTotal = $address->getGrandTotal(); $baseGrandTotal = $address->getBaseGrandTotal(); $totals = array_sum($address->getAllTotalAmounts()); $baseTotals = array_sum($address->getAllBaseTotalAmounts()); $address->setGrandTotal(round(($grandTotal+$totals),2)); //Modificated $address->setBaseGrandTotal(round(($baseGrandTotal+$baseTotals),2)); //Modificated //$address->setGrandTotal($grandTotal+$totals); --Original //$address->setBaseGrandTotal($baseGrandTotal+$baseTotals); --Original return $this; } Is there a way to simultaneously round the subtotal and tax?I tried to do so in the other files in the above mentioned directory but without result. 解决方案 I know this question is rather old but I had exactly the same problem recently. So here is my solution which seems to work fine so far.public function collect(Mage_Sales_Model_Quote_Address $address){ $grandTotal = round($address->getGrandTotal(), 2); $baseGrandTotal = round($address->getBaseGrandTotal(), 2); $subTotal = round($address->getSubtotal(), 2); $baseSubTotal = round($address->getBaseSubtotal(), 2); $taxAmount = round($address->getTaxAmount(), 2); $baseTaxAmount = round($address->getBaseTaxAmount(), 2); $shippingAmount = round($address->getShippingAmount(), 2); $baseShippingAmount = round($address->getBaseShippingAmount(), 2); $address->setSubtotal($subTotal); $address->setBaseSubtotal($baseSubTotal); $address->setTaxAmount($taxAmount); $address->setBaseTaxAmount($baseTaxAmount); $address->setShippingAmount($shippingAmount); $address->setBaseShippingAmount($baseShippingAmount); $address->setGrandTotal($grandTotal + $subTotal + $shippingAmount + $taxAmount); $address->setBaseGrandTotal($baseGrandTotal + $baseSubTotal + $baseShippingAmount + $baseTaxAmount); return $this;} 这篇关于magento轮小计,总计和税款的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-30 00:01