I m trying to recalculate magento total using magento event observer after placing order.I m use below code to calculate total.

Observer Functon

public function recalculateTotal($observer)
    $orderModel = $observer->getOrder();
    //echo "<pre>";print_r($orderModel->getData());echo "</pre>";exit;
    $saveModel = Mage::getModel('sales/order')->load($orderModel->getId());
    echo "<pre>";print_r($orderModel->getData());echo "</pre>";exit;



But this is not working Please help.


You need to change all order totals directly in your method:

$orderModel = $observer->getOrder();
$orderModel->setSurchargeAmount(10); // usually all totals has "amount" suffix
$orderModel->setGrandTotal($orderModel->getGrandTotal() + 10);
$orderModel->setBaseGrandTotal($orderModel->getBaseGrandTotal() + 10);
try {
} catch (Exception $e) {
    echo $e->getMessage();
echo "<pre>";
echo "</pre>";
  • Yes we can this but this is not ideal way to change grandtotal like this may be magento has good way to do this. – Zaheerabbas Mar 28 '16 at 6:43
  • Good way is convert the quote to the order. In other way you should calculate base totals in your code. – Siarhey Uchukhlebau Mar 28 '16 at 6:48

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.