0

I have an order data without shipping included, i tried to re-calculate total order when adding shipping price like this:

$shippingAmount = '30000';
$quote = $this->getQuote();
$quote->setGrandTotal($quote->getGrandTotal() + $shippingAmount);

but the above code won't recalculate total discount and tax

1 Answer 1

0

Once you set the Shipping method, you should tell magento to Collect Totals again. Refer below code:

$onepage = Mage::getSingleton('checkout/type_onepage');
$quote = $onepage->getQuote();
$shippingMethod = 'shipping_method_code';
$onepage->saveShippingMethod($shippingMethod);
$onepage->getQuote()->collectTotals()->save();

The above code will work if you have a shipping method with code 'shipping_method_code' for the shipping address you selected. Read the tutorial to learn how to create a shipping method Here or use any existing shipping methods like USPS, UPS, Flat Rate etc.

2
  • that makes my grand total 0 Commented Dec 13, 2017 at 12:24
  • Paste your code
    – Nidheesh
    Commented Dec 13, 2017 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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