magento圆形小计,总和税

时间:2014-11-26 16:57:12

标签: magento rounding

我已经安装了ET货币管理器,以便通过格拉姆销售产品,价格< 0.01每格拉。

问题在于,这有时会导致小计费用,税金和总计半美分...(除了paypal问题)对客户造成混淆并且不可接受

因此,我正在寻找一种解决方案,将小计,税金和总价值四舍五入到小数点后两位。

我知道ET货币经理有选项&#34;从结账时排除&#34;但这导致了其他问题因此与这个问题无关(如果我在这里没有得到解决方案,我会单独提出这个问题)

我通过更改以下功能设法绕过总计:

应用\代码\核心\法师\ SALES \模型\报价\地址\总\ 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;
    } 

有没有办法同时围绕小计和税收? 我试图在上面提到的目录中的其他文件中这样做但没有结果。

1 个答案:

答案 0 :(得分:0)

我知道这个问题相当陈旧,但最近我遇到了完全相同的问题。所以这是我的解决方案,到目前为止似乎工作正常。

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;
}