Php Magento在Ajax中调用collectTotals()后计算两次grandtotal

Php Magento在Ajax中调用collectTotals()后计算两次grandtotal,php,magento,Php,Magento,我正在尝试在Magento结帐中应用折扣后的发货金额 我使用的是UPS免费送货的价格,因此,如果您的总折扣低于免费送货的最低金额,它将不会授予您免费送货 Magento计算折扣前的免费送货,因此我在本地ups.php文件中计算了折扣后的正确金额,并将其应用于代码: $coupon_code=Mage::getSingleton('checkout/cart')->getQuote()->getCouponCode(); Mage::getSingleton("che

我正在尝试在Magento结帐中应用折扣后的发货金额

我使用的是UPS免费送货的价格,因此,如果您的总折扣低于免费送货的最低金额,它将不会授予您免费送货

Magento计算折扣前的免费送货,因此我在本地ups.php文件中计算了折扣后的正确金额,并将其应用于代码:

$coupon_code=Mage::getSingleton('checkout/cart')->getQuote()->getCouponCode();
         Mage::getSingleton("checkout/session")->setData("coupon_code",$coupon_code);
         Mage::getSingleton('checkout/session')->getQuote()->setCouponCode($coupon_code)->setTotalsCollectedFlag(false)->collectTotals();
         //Mage::getSingleton('checkout/cart')->getQuote()->setCouponCode($coupon_code)->collectTotals()->save();
         $totals =Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object
         $subtotal = $totals["subtotal"]->getValue(); //Subtotal value

        if(isset($totals['discount']) && $totals['discount']->getValue()) {
            $discount = $totals['discount']->getValue(); //Discount value if applied
        } else {
            $discount = '';
        }       
    $r->setValue($request->getPackageValueWithDiscount( ) - $giftCardPrice);
    if($discount!='')  $r->setValueWithDiscount($subtotal-abs($discount));  
    else $r->setValueWithDiscount($request->getPackageValueWithDiscount( )- $giftCardPrice);
这解决了我的问题,因为在每次装运Magento的Ajax调用中,都会计算两次购物车的总计


我能做什么?

您使用的是哪一版本的Magento?使用Magento Enterprise 1.9$r是$r=新的Varien_对象();应用于$this->\u rawRequest=$r;到年底,收取费用