I created a custom charges on order for some specific products, Unfortunately custom charge was not updated in order total like cash on delivery,

Is there any way to update orders totals after order created without cancel order?


I think you can do this just like you would modify any other model instance.

$item = Mage::getModel('sales/order_item')->load(id here);


$order = Mage::getModel('sales/order')->load(order id here);

You might also need to change other values like tax, subtotal_incl_tax and others.

But this is a bad practice and you should not do it. It is better just to cancel the order and create a new one.

  • I was looking for Bulk order update, like COD was not there, That's why cancel order way not adopted, Thank you, Works for me. – Ram Pratap Singh Gour Oct 7 '16 at 4:54

Here I have created a solution to set custom item price and recalculate all the order totals.

We will need to calculate manually as the collectTotals will not work after an order is placed.

require_once('app/Mage.php'); //Path to Magento
echo "<pre>";

$customProductPrice = 5; // Custom Product Price For One Quantity
$item = Mage::getModel('sales/order_item')->load(15); //Order Itemid
if($item): //Check item object exists or not
    $quantity = $item->getQtyOrdered();
    $rowTotal = $customProductPrice * $quantity;

    # calculateTaxAmount
    if (!empty($item->getTaxPercent())) {
        $taxAmount = ($rowTotal * $item->getTaxPercent()) / 100;

    #  Price In Grid Update

    #Subtotal On Order * Qty

    # Apply Item Discounted Amount (Recaculated Discount)
    if (!empty($item->getDiscountPercent())) {
        $discountedAmount = $item->getRowTotal()*$item->getDiscountPercent()/100;

    $order = Mage::getModel('sales/order')->load(11); //Orderid
    $orderSubTotal = 0;
    $orderBaseTax = 0;
    $orderDiscountAmount = 0;
    foreach ($order->getAllVisibleItems() as $_item) {
        $orderSubTotal += $_item->getBaseRowTotal();
        $orderBaseTax += $_item->getBaseTaxAmount() + $_item->getBaseHiddenTaxAmount();
        $orderDiscountAmount += $_item->getBaseDiscountAmount();

    $grandTotal = ($orderSubTotal + $order->getShippingAmount() + $orderBaseTax) - $orderDiscountAmount;

    # Update Order Totals
  • Thanks works perfectly – Suneth Kalhara Aug 21 '20 at 15:38
  • I converted this to magento2 if anyone needs it @ me, works perfectly! – Gaz Smith Jul 16 at 7:56

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.