I use Magento CE and I have developed a php script that can delete a product from an order. After the product is deleted the value of the order is the same. How can I reduce the order value with the amount of the deleted product?

My script:

$base_grand_total = $order->getBaseGrandTotal();

$base_subtotal = $order->getBaseSubtotal();
$base_tva = $order->getBaseTaxAmount();

$grand_total = $order->getGrandTotal();

$subtotal = $order->getSubtotal();
$tva = $order->getTaxAmount();

$base_subtotal_incl_tax = $order->getBaseSubtotalInclTax();

$subtotal_incl_tax = $order->getSubtotalInclTax();

$total_item_count = $order->getTotalItemCount();

$item_price = $sItem->getPrice();

$item_tva = $sItem->getTaxAmount();











  • can you put your script?
    – Amit Bera
    Sep 10, 2014 at 10:01
  • I added the script in first post.
    – aceveve
    Sep 10, 2014 at 11:25
  • After a quote (cart) becomes an order, the cart will be empty. How can you reduce the value of the cart if it has already converted to an order? Sep 10, 2014 at 12:41
  • Sorry, my mistake. I want to reduce the value of the order, not my cart, of course. Sorry again.
    – aceveve
    Sep 10, 2014 at 12:45

3 Answers 3


I hope you do not need to remove all items. so there should be some condition over delete item and update order within it.

Following Works for me.

Just have done conditional update for order and delete for the item.and removed item price from base_subtotal too.

$_order = Mage::getModel('sales/order')->load(order_id);
$items = $_order->getAllItems();
foreach ($items as $item){
$base_grand_total = $_order->getBaseGrandTotal();

$base_subtotal = $_order->getBaseSubtotal();
$base_tva = $_order->getBaseTaxAmount();

$grand_total = $_order->getGrandTotal();

$subtotal = $_order->getSubtotal();
$tva = $_order->getTaxAmount();

$base_subtotal_incl_tax = $_order->getBaseSubtotalInclTax();

$subtotal_incl_tax = $_order->getSubtotalInclTax();

$total_item_count = $_order->getTotalItemCount();

    $item_price = $item->getPrice();
    $item_tva = $item->getTaxAmount();











You need to call collect totals on the quote object:


Just an update to @Namita answer.


$_order = Mage::getModel('sales/order')->loadByIncrementId('100000053');
$items = $_order->getAllItems(); 

in the first line if the above one is not working for you. Just tried it from magento root as external code with this update. It works fine !

Please let me know if the complete lines of code required.


require_once('app/Mage.php'); //Path to Magento

// $_order = Mage::getModel('sales/order')->load(order_id);
$_order = Mage::getModel('sales/order')->loadByIncrementId('100000053');
$items = $_order->getAllItems(); 
echo "success"; 
} catch(Exception $e) {
    echo "failed";

Your Answer

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

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