I use Magento CE 1.8.1.0 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();
$sItem->delete();
$order->setBaseGrandTotal($base_grand_total-$item_price-$item_tva);
$order->setBaseSubtotal($base_subtotal);
$order->setBaseTaxAmount($base_tva-$item_tva);
$order->setGrandTotal($grand_total-$item_price-$item_tva);
$order->setSubtotal($subtotal-$item_price);
$order->setTaxAmount($tva-$item_tva);
$order->setBaseSubtotalInclTax($base_subtotal_incl_tax-$item_price);
$order->setSubtotalInclTax($subtotal_incl_tax-$item_price);
$order->setTotalItemCount($total_item_count-1);
$order->save();