How to delete a shipment from Magento that was created accidentally?

How to delete a shipment from Magento that was created accidentally?

July 24, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to delete a shipment from Magento that was created accidentally?

Deleting Accidental Shipments from Magento (Version 1.1.8)

Accidentally creating shipments can happen even to the most seasoned e-commerce store managers. In scenarios like this, it’s crucial to know how to reverse a shipment and reset an order back to its original status without impacting your inventory or sales records.

Understanding the Problem

In Magento 1.1.8, there is no built-in functionality to delete shipments from the admin panel once they have been created. This limitation exists because shipments are tied directly to orders and the order history cannot be altered.

However, this doesn’t mean you’re out of options. With a bit of PHP and MySQL knowledge, it’s possible to programmatically remove these shipments and reset the order status using custom code.

The Solution: Reversing Shipments via Custom Script

To achieve this, we need to perform two primary tasks:

  1. Delete the existing shipment data from the database.
  2. Update the order status back to “processing”.

Here’s a PHP script that demonstrates how you can accomplish this:

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

// Get the order ID of the shipment you want to delete
$orderId = 100005;

// Load the order object
$order = Mage::getModel('sales/order')->load($orderId);

// Loop through all shipments for this order and delete them
foreach ($order->getShipmentsCollection() as $shipment) {
    // Delete the shipment object
    $shipment->delete();
}

// Update the order status back to "processing"
$order->setStatus('processing');
$order->save();

This script first loads an instance of the sales/order model based on your specified order ID. It then retrieves all associated shipments using the getShipmentsCollection() method.

For each shipment, it deletes the object by calling the delete() function.

Finally, it updates the status of the original order back to “processing” and saves the changes.

Deleting Shipments Directly via MySQL

If you prefer a more direct approach using SQL queries, you can manually delete the shipment data. However, this method requires careful handling as it involves raw database manipulation.

Here are the tables you need to consider:

  • sales_shipment_track
  • sales_shipment_grid
  • sales_shipment

To delete all shipments for an order with ID 100005 using MySQL, you can execute the following query:

DELETE FROM sales_shipment WHERE entity_id = 100005;
DELETE FROM sales_shipment_track WHERE parent_id IN (
    SELECT entity_id FROM sales_shipment WHERE entity_id = 100005
);
DELETE FROM sales_shipment_grid WHERE entity_id = 100005;

This query deletes all rows from the sales_shipment table that match your order ID. It then recursively deletes any associated track records and grid data.

Conclusion

While Magento lacks a built-in mechanism for deleting shipments, it’s possible to achieve this using custom PHP scripts or direct MySQL queries.

Remember, always backup your database before performing these operations to prevent data loss.

For more advanced scenarios involving bulk shipment deletion or complex order status changes, I recommend exploring the Laravel Company’s Magento 2 development services for a professional approach.

Ensure you thoroughly test this script in your development environment before deploying it to your live site to avoid any potential disruptions to your operations.

Magento 1 Database Admin Orders

Our network