Magento – How to recalculate shipping costs in Magento one page checkout

checkoutshipping

I have the following requirement for a shipping module in Magento:
on the shipping method step on one page checkout in Magento, the user should be able to add additional options to a particular method (are there any fragile items, pick up from warehouse, add insurance etc.). Based on that, I have to recalculate shipping costs. In essence, I need to get the submitted options, make an API call, and represent the new costs to the user. Currently I have overriden Checkout_OnepageController successfully.
How can I repeat that step?

Best Answer

You can recalculate totals by using collectTotals() method in app/code/core/Mage/Sales/Model/Quote/Address.php by getting the quote. For example:

$this->getQuote()->collectTotals();

Regards,

Related Topic