1

I wish to change the tax amount in checkout programmatically I am using following code let me know If I am making any mistake.

$session= Mage::getSingleton("checkout/session");
$quote_id = $session->getQuoteId();
$quote = Mage::getModel("sales/quote")->load($quote_id);
$items = $quote->getAllItems();
foreach($items as $item) { 
   $item->setTaxAmount(0);
   $item->setBaseTaxAmount(0);
   $item->setPriceInclTax($value);
   $item->setBasePriceInclTax($value);
   $item->save();
   $quote->save();
}
7
  • you use this code inside event observers? Apr 11 '15 at 5:09
  • I am using it in Model file Apr 11 '15 at 5:14
  • ok. Can you try with this event sales_quote_collect_totals_after Apr 11 '15 at 5:30
  • But I want to change this before placing order and only on checkout page Apr 11 '15 at 5:36
  • yes you can the tax with the above events Apr 11 '15 at 5:38
6

After Long research and trials Finally I come up with this solution.

$finalPrice = $product->getPrice();
    $item = Mage::getSingleton('checkout/session')->getQuote()->getItemByProduct($product);
    $finalprice = $finalPrice - $item->getTaxAmount();
    $quote = Mage::getModel('checkout/session')->getQuote();
    $address = $quote->getShippingAddress();
    if ($address)
    {   $address->setSubtotalInclTax($finalprice);
        $product->setTaxClassId(0);
        $product->setPrice($finalprice);

     }
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.