Advisory
Please use extreme caution when using this modification. It is unforgiving. Make a mistake and you're restoring your database. There is no "Undo". Seriously. There is also no "Are you sure?" when using this modification. Real site admins don't need it (plus I don't know how to add one) 

Introduction
There are many times where I have found the need to delete an order. It usually involves my own testing or an unusual payment processing failure.
When an order gets messed up, the customer usually places another order, if they even know there was a problem. Usually this results in 3-4 bad orders on the Admin side. there's no way to delete them, so you're forced to sort "around" them as you work to process your business. It also forces the customer to live with a really confusing order history.

This modification allows the Admin to delete a single or group of orders right from Admin screen using the "Update Selected Orders" feature.

How it works
This modification uses the same concept already built into the Update Selected Orders dropdown. Just click the checkboxes for the orders to delete, select the "Delete" dropdown option and click Go.

Modifications
First make a backup copy of your ~/Admin/Orders/default.aspx and default.aspx.cs files. These are the files we will be changing in this modification.

Edit ~/Admin/orders/Default.aspx file and look for the start of the dropdown list control – here is some of this code:

Code:
                                <asp:DropDownList ID="BatchAction" runat="server">
                                    <asp:ListItem Text=""></asp:ListItem>
                                    <asp:ListItem Text="Process Payment" Value="PAY"></asp:ListItem>
                                    <asp:ListItem Text="Mark Shipped" Value="SHIP"></asp:ListItem>
                                    <asp:ListItem Text="Mark Shipped with Options" Value="SHIPOPT"></asp:ListItem>
                                    <asp:ListItem Text="Cancel" Value="CANCEL"></asp:ListItem>
                                    <asp:ListItem Text="———–"></asp:ListItem>

Directly below the first "————" ListItem entry you see, add this code:

Code:
                                    <asp:ListItem Text="* DELETE *" Value="DELETE"></asp:ListItem>
                                    <asp:ListItem Text="———–"></asp:ListItem>

Save it.

Now edit the ~/Admin/Orders/Default.aspx.cs file. Find the code located in the BatchButton_Click function that looks like this:

Code:
                    case "SHIPOPT":
                        Response.Redirect("Batch/Ship.aspx?orders=" + GetOrderList(orderIds));
                        break;

We need to Insert another CASE section of code like this directly below the "break;" line. So add the following code as described:

Code:
                    case "DELETE":
                        int DelCount = 0;
                        foreach (int orderId in orderIds)
                        {
                            Order order = OrderDataSource.Load(orderId);
                            if (order != null)
                            {
                                order.Delete();
                                messages.Add("Order #" + order.OrderId + " deleted.");
                                DelCount++;
                            }
                        }
                        messages.Add(DelCount + " orders deleted.");
                        break;

Save it.

Testing
It's critical you test this in your development environment first. There is no "Undo" feature – once an order is deleted, it's gone. Note how you can delete one order at a time, or delete multiple orders in a single command. Test both scenarios and confirm the properly selected orders were removed and no others.

Cascade Deletes
Deleting an order cascades through the other files automatically. Payment records, notes and history, shipments etc will also be automatically deleted. There should be no trace of the order left when the command is finished.

Conclusion
Order management is a key point in the business process where mistakes can be made. Clearing out unwanted orders helps the admin keep a clean running store with less potential for errors. It also gives the customer a good looking order history to review their purchases.