Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tegansnyder/4287245 to your computer and use it in GitHub Desktop.
Save tegansnyder/4287245 to your computer and use it in GitHub Desktop.
Magento load an order by IncrementId and clear and discounts that applied on the order.
<?php
error_reporting(E_ALL | E_STRICT);
require_once 'app/Mage.php';
Varien_Profiler::enable();
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app('default');
$order = Mage::getModel('sales/order')->loadByIncrementId('100126630');
$original_price = 0;
foreach ($order->getAllItems() as $itemId => $item) {
$item->setDiscountAmount(0);
$item->setOriginalPrice($item->getOriginalPrice());
$item->save();
$original_price += $item->getOriginalPrice();
}
$order->setGrandTotal($original_price);
$order->setBaseGrandTotal($original_price);
$order->setTotalPaid(0);
$order->setShippingAmount(0);
$order->setBaseShippingAmount(0);
$order->save();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment