A Magento order could be cancelled by mistake, but there is no way to undo this action - at least not in the GUI. There might be excellent third party modules providing this functionality, but you could also write just a simple PHP-script to accomplish the same task.

The clue to uncancel an order, is that - while you can change the order itself by changing its state and status, you also need to uncancel the order-items within that order. The following PHP-script could be run from the command-line to uncancel a specific order.

<?php
require_once 'app/Mage.php';
Mage::app();

$order = Mage::getModel('sales/order')->load(1382);
$order->setState(Mage_Sales_Model_Order::STATE_COMPLETE);
$order->setStatus(Mage_Sales_Model_Order::STATE_COMPLETE);
$order->save();

foreach ($order->getAllItems() as $item) {
    $item->setQtyCanceled(0);
    $item->save();
}
Posted on July 17, 2010

About the author

Author Jisse Reitsma

Jisse Reitsma is the founder of Yireo, extension developer, developer trainer and 3x Magento Master. His passion is for technology and open source. And he loves talking as well.

Sponsor Yireo

Upcoming events

Oct
28
Oct
31
LIEF Amsterdam
Nov
08

Looking for a training in-house?

Let's get to it!

We schrijven niet te commerciële dingen, we richten ons op de technologie (waar we dol op zijn) en we komen regelmatig met innovatieve oplossingen. Via onze nieuwsbrief kun je op de hoogte blijven van al deze coolness. Inschrijven kost maar een paar seconden.

Do not miss out on what we say

This will be the most interesting spam you have ever read

We schrijven niet te commerciële dingen, we richten ons op de technologie (waar we dol op zijn) en we komen regelmatig met innovatieve oplossingen. Via onze nieuwsbrief kun je op de hoogte blijven van al deze coolness. Inschrijven kost maar een paar seconden.