mage2kishan / module-order-cleanup
Panth Order Cleanup — safely delete test orders, invoices, shipments, and credit memos from Magento 2 with double verification, deletion logs, and admin-configurable safety controls. Keeps your order data clean and organized.
Package info
github.com/mage2sk/module-order-cleanup
Type:magento2-module
pkg:composer/mage2kishan/module-order-cleanup
Requires
- php: ~8.1.0||~8.2.0||~8.3.0||~8.4.0
- mage2kishan/module-core: ^1.0
- magento/framework: ^103.0
- magento/module-backend: ^102.0
- magento/module-sales: ^103.0
- magento/module-ui: ^101.2
README
Panth Order Cleanup — Safely Delete Orders from Magento 2
Permanently delete test orders, junk data, and unwanted transactions from your Magento 2 admin — with double verification, configurable safety controls, mass delete support, and a complete audit trail. Built for store owners who need a clean order history without the risk.
Magento 2 doesn't allow deleting orders out of the box. Panth Order Cleanup adds this missing functionality with industry-leading safety measures: a configurable delete button on every order view page, a mass delete action in the order grid, double confirmation with order ID verification (like GitHub's repo delete), per-status restrictions, and a detailed deletion log that records every deletion with admin user, IP address, timestamp, and a full snapshot of the deleted order data.
Preview
Mass Delete from Order Grid
Select multiple orders and choose "Delete Orders (Permanent)" from the mass actions dropdown.
Delete Button on Order View
A configurable "Delete This Order" button appears on every order detail page.
Double Confirmation Modal
Type the order number to confirm — prevents accidental deletions, inspired by GitHub's repository delete flow.
Deletion Audit Log
Every deletion is logged with order details, admin user, IP address, method, and timestamp.
Admin Configuration
Full control over button appearance, safety requirements, allowed statuses, and mass delete limits.
Need Custom Magento 2 Development?
Kishan SavaliyaTop Rated Plus on Upwork |
Panth Infotech Agency |
Table of Contents
- Key Features
- What Gets Deleted
- Safety Controls
- Compatibility
- Installation
- Configuration
- How It Works
- Deletion Audit Log
- Troubleshooting
- FAQ
- Support
Key Features
- Delete Button on Order View — configurable button with custom text and color on every order detail page
- Mass Delete Action — select multiple orders from the grid and delete them all at once
- Double Confirmation Modal — confirmation popup with order details and data impact warning
- Type Order ID to Confirm — inspired by GitHub's repo delete flow, requires typing the exact order number to proceed
- Per-Status Restrictions — only allow deletion of orders with specific statuses (Pending, Canceled, etc.)
- Configurable Related Data Deletion — choose whether to delete invoices, shipments, credit memos, and payment transactions
- Complete Audit Trail — every deletion logged with order snapshot, admin user, IP address, timestamp, and method
- Mass Delete Safety Limit — configurable maximum orders per mass action (default: 50)
- ACL Permissions — separate permissions for single delete, mass delete, and log viewing
- Transaction-Safe — all deletions wrapped in database transactions with automatic rollback on failure
- Quote Cleanup — optionally removes the associated quote, quote items, addresses, payments, and shipping rates
- Magento-Native Styling — button and modal match Magento's admin design language perfectly
- MEQP Compliant — passes Adobe Marketplace code quality standards
- Zero Frontend Impact — admin-only module, no storefront code
What Gets Deleted
When you delete an order, the following data is permanently removed (each configurable):
| Data | Table(s) | Configurable |
|---|---|---|
| Order record | sales_order, sales_order_grid |
Always deleted |
| Order items | sales_order_item |
Always deleted |
| Order payments | sales_order_payment |
Always deleted |
| Order addresses | sales_order_address |
Always deleted |
| Status history | sales_order_status_history |
Always deleted |
| Order tax | sales_order_tax |
Always deleted |
| Invoices | sales_invoice, sales_invoice_grid, sales_invoice_item, sales_invoice_comment |
Yes |
| Shipments | sales_shipment, sales_shipment_grid, sales_shipment_item, sales_shipment_comment |
Yes |
| Credit memos | sales_creditmemo, sales_creditmemo_grid, sales_creditmemo_item, sales_creditmemo_comment |
Yes |
| Payment transactions | sales_payment_transaction |
Yes |
| Quote data | quote, quote_item, quote_address, quote_payment, quote_shipping_rate |
Always (if quote exists) |
Safety Controls
Panth Order Cleanup is designed with safety first. Multiple layers of protection prevent accidental data loss:
Layer 1: Admin Permissions (ACL)
Panth_OrderCleanup::delete_order— required to see and use the delete buttonPanth_OrderCleanup::mass_delete— required for mass delete actionPanth_OrderCleanup::view_log— required to view deletion log
Layer 2: Confirmation Modal
- Shows exactly what data will be deleted (invoices, shipments, credit memos, quote data)
- Warns that the action is permanent and cannot be undone
Layer 3: Type Order ID to Confirm
- User must type the exact order increment ID (e.g.,
000000031) before the delete button becomes active - Inspired by GitHub's repository deletion flow — the gold standard for destructive action confirmation
Layer 4: Status Restrictions
- Configure which order statuses are allowed for deletion
- Example: only allow deleting "Pending" and "Canceled" orders, protecting "Complete" and "Processing" orders
Layer 5: Mass Delete Safety Limit
- Configurable maximum number of orders per mass action (default: 50)
- Prevents accidentally selecting "all" and deleting thousands of orders
Layer 6: Database Transactions
- Every deletion is wrapped in a transaction
- If any step fails, everything is rolled back — no partial deletions
Layer 7: Audit Log
- Every deletion is permanently logged with full order details
- Cannot be disabled independently of the deletion feature
- Tracks who deleted what, when, from where, and how
Compatibility
| Requirement | Versions Supported |
|---|---|
| Magento Open Source | 2.4.4, 2.4.5, 2.4.6, 2.4.7, 2.4.8 |
| Adobe Commerce | 2.4.4, 2.4.5, 2.4.6, 2.4.7, 2.4.8 |
| Adobe Commerce Cloud | 2.4.4 — 2.4.8 |
| PHP | 8.1, 8.2, 8.3, 8.4 |
| Panth Core | ^1.0 (installed automatically) |
Installation
Composer (Recommended)
composer require mage2kishan/module-order-cleanup bin/magento module:enable Panth_Core Panth_OrderCleanup bin/magento setup:upgrade bin/magento setup:di:compile bin/magento cache:flush
Manual Installation
- Download and extract to
app/code/Panth/OrderCleanup/ - Run the enable commands above
Verify
bin/magento module:status Panth_OrderCleanup
# Module is enabled
Navigate to Sales > Orders to see the mass delete action, or open any order to see the delete button.
Configuration
Navigate to Stores > Configuration > Panth Extensions > Order Cleanup.
General
| Setting | Default | Description |
|---|---|---|
| Enable Order Cleanup | Yes | Master toggle for all order deletion features |
Delete Button on Order View
| Setting | Default | Description |
|---|---|---|
| Show Delete Button on Order View | Yes | Add a "Delete This Order" button to the order detail page |
| Button Text | Delete This Order | Custom text for the delete button |
| Button Color | #DC2626 (red) | Hex color for the delete button background |
Safety & Data Controls
| Setting | Default | Description |
|---|---|---|
| Require Confirmation Modal | Yes | Show a confirmation popup before deleting any order |
| Require Typing Order ID to Confirm | Yes | User must type the order increment ID to confirm deletion |
| Delete Related Invoices | Yes | Also delete all invoices related to the order |
| Delete Related Shipments | Yes | Also delete all shipments related to the order |
| Delete Related Credit Memos | Yes | Also delete all credit memos related to the order |
| Delete Related Payment Transactions | Yes | Also delete all payment transactions related to the order |
| Keep Deletion Log | Yes | Log every deletion with order details, admin user, timestamp, and IP address |
| Allowed Order Statuses for Deletion | (empty = all) | Only orders with these statuses can be deleted. Leave empty to allow all statuses |
Mass Delete
| Setting | Default | Description |
|---|---|---|
| Enable Mass Delete Action | Yes | Add "Delete Orders" to the mass action dropdown in the order grid |
| Require Confirmation for Mass Delete | Yes | Show confirmation dialog before mass deleting orders |
| Maximum Orders Per Mass Action | 50 | Safety limit on how many orders can be deleted in a single mass action |
How It Works
Single Order Deletion
- Admin opens an order detail page
- Clicks the "Delete This Order" button
- Confirmation modal appears showing all data that will be deleted
- Admin types the order number to confirm (if enabled)
- Clicks "Yes, Permanently Delete"
- Module checks: enabled? allowed status? ACL permission?
- Database transaction begins
- Related data deleted (invoices, shipments, credit memos, transactions)
- Order items, payments, addresses, status history, tax deleted
- Quote and quote-related data deleted
- Order and order grid record deleted
- Transaction committed
- Deletion logged to audit trail
- Admin redirected to order grid with success message
Mass Deletion
- Admin selects orders in the order grid
- Chooses "Delete Orders (Permanent)" from mass actions
- Confirmation dialog appears with warning
- Module checks safety limit (default: 50 orders max)
- Each order processed individually through the same deletion flow
- Success/failure count reported with detailed messages
Deletion Audit Log
Navigate to Panth Infotech > Order Cleanup > Deletion Log to view all deletions.
The log captures:
| Field | Description |
|---|---|
| ID | Auto-increment log entry ID |
| Order # | The deleted order's increment ID |
| Customer | Customer name |
| Customer email address | |
| Grand Total | Order total with currency |
| Status at Deletion | Order status when it was deleted |
| Items | Number of items in the order |
| Invoices Deleted | Whether invoices were deleted |
| Shipments Deleted | Whether shipments were deleted |
| Deleted By | Admin username who performed the deletion |
| Method | "single" (from order view) or "mass" (from grid) |
| IP Address | Admin user's IP address |
| Deleted At | Exact timestamp of deletion |
The audit log is stored in the panth_order_deletion_log database table and persists even if the order data is gone — providing a permanent record for accounting and compliance.
Troubleshooting
| Issue | Solution |
|---|---|
| Delete button not visible | Check: module enabled, button enabled in config, ACL permission granted |
| Clicking delete redirects to dashboard | Clear cache, run setup:di:compile. The block must extend Backend\Block\Template for form key support |
| "Order Cleanup is currently disabled" | Enable it at Stores > Configuration > Panth Extensions > Order Cleanup > General > Enable = Yes |
| "Status not allowed for deletion" | Check Allowed Order Statuses in Safety config — add the order's status or leave empty to allow all |
| "Safety limit exceeded" | Reduce selection or increase Maximum Orders Per Mass Action in config |
| Deletion log shows "Table not found" | Run bin/magento setup:upgrade to create the panth_order_deletion_log table |
| Mass delete not in dropdown | Enable Mass Delete Action in config and check Panth_OrderCleanup::mass_delete ACL permission |
| SQL error on quote_shipping_rate | Update to latest version — fixed in 1.0.0 (shipping rates use address_id via quote_address) |
FAQ
Is this safe to use on production?
Yes. The module includes 7 layers of safety controls (ACL, confirmation modal, type-to-confirm, status restrictions, mass delete limit, database transactions, and audit logging). It was designed for production use where store owners need to clean up test orders or remove unwanted transactions.
Can I recover a deleted order?
No. Deletion is permanent — that's the point. However, the deletion log preserves a snapshot of the order data (customer, items, totals, timestamps) for accounting and audit purposes. We strongly recommend keeping the deletion log enabled.
Does it delete from third-party tables?
No. The module only deletes from core Magento sales and quote tables. If you have third-party extensions that add related tables (e.g., custom shipping providers, ERP sync logs), those records may become orphaned. Check with your extension vendors.
Does it affect reports?
Yes. Deleted orders are removed from all Magento reports since the underlying data no longer exists. The deletion log can serve as an alternative record for accounting.
Can I restrict who can delete orders?
Yes. The module uses Magento's ACL system with three separate permissions:
Panth_OrderCleanup::delete_order— single order deletionPanth_OrderCleanup::mass_delete— mass deletion from gridPanth_OrderCleanup::view_log— viewing the deletion log
Assign these per admin role under System > Permissions > User Roles.
Does it work with Hyva theme?
Yes. This is an admin-only module — it works identically regardless of your frontend theme (Hyva, Luma, or custom).
What happens if deletion fails midway?
The entire operation is rolled back. Database transactions ensure that either everything is deleted cleanly, or nothing changes. You'll see an error message explaining what went wrong, and the system log will have details.
Can I customize the delete button appearance?
Yes. You can change the button text and color from admin config. The button uses Magento's native admin button classes for consistent styling.
Support
| Channel | Contact |
|---|---|
| kishansavaliyakb@gmail.com | |
| Website | kishansavaliya.com |
| +91 84012 70422 | |
| GitHub Issues | github.com/mage2sk/module-order-cleanup/issues |
| Upwork (Top Rated Plus) | Hire Kishan Savaliya |
| Upwork Agency | Panth Infotech |
Need Custom Magento Development?
License
Proprietary — see LICENSE.txt. One license per Magento production installation.
About Panth Infotech
Built and maintained by Kishan Savaliya — kishansavaliya.com — Top Rated Plus Magento developer on Upwork with 10+ years of eCommerce experience.
Panth Infotech specializes in high-quality Magento 2 extensions and themes for Hyva and Luma storefronts. Browse our full catalog of 35+ extensions on Packagist and the Adobe Commerce Marketplace.
Quick Links
- kishansavaliya.com
- Get a Quote
- Upwork Profile
- Panth Infotech Agency
- All Packages on Packagist
- GitHub
SEO Keywords: magento 2 delete orders, magento order cleanup, remove test orders magento 2, magento 2 order management, delete invoices shipments magento, magento order deletion extension, magento 2 mass delete orders, magento 2 admin order tools, magento order audit log, magento 2 order cleanup extension, magento delete order safely, magento order deletion log, magento 2 double confirmation delete, magento order status restriction, magento 2 acl order delete, panth order cleanup, panth infotech, mage2kishan, mage2sk, hire magento developer, top rated plus upwork, magento 2 extension developer, magento 2.4.8 delete orders




