Skip to content
Admin & Security Extensions

Order Cleanup: Delete Orders for Magento 2

Delete test and unwanted orders from the Magento 2 admin, from the order view or with a mass action in the order grid. Only the statuses you allow can be deleted, and each deletion is logged with the admin user and IP address. Deletions are permanent, so back up first.

  • Free
  • Themes listed: Hyvä + Luma
Free $0.00, in stock
Check requirementsSee the versions and themes listed for this package. Details Ask about setupInclude the package name and your Magento and PHP versions. Ask
$0.00
In stock
SKU
panth-order-cleanup
Links
composer require mage2kishan/module-order-cleanup
SKU
panth-order-cleanup
  • Package requirementsRead the source documentation
  • Developer profileView Upwork profile
  • Themes listedHyvä + Luma
  • PHP versions listed8.1, 8.2, 8.3, 8.4
  • Installation questionsDiscuss your store setup

What it does for your store

The main features, as listed in the module documentation.

  • Delete from the order view

    A Delete This Order button with your own text and colour, and a confirmation dialog that can require typing the order number.

  • Mass delete in the order grid

    A Delete Orders (Permanent) action for up to 50 orders per run by default; above the limit nothing is deleted. Orders that fail a check are skipped and reported.

  • Status limits and permissions

    Only canceled, closed, on hold, pending and fraud orders can be deleted by default, and four ACL resources control who can configure, delete, mass delete or view the log.

  • Deletion log

    Order number, customer, grand total, status, items, related documents, admin user, IP address, method and time, written in the same transaction as the delete.

Installation

Example commands from the Magento root. Follow the package instructions and your staging and deployment process.

  1. 1Check the releaseMatch Magento, PHP, theme and dependency requirements.
  2. 2Install on stagingReview Composer changes and follow the package instructions.
  3. 3Configure and verifyUse the documented settings and test the affected features.
magento-root
$ composer require mage2kishan/module-order-cleanup
$ bin/magento setup:upgrade
$ bin/magento setup:di:compile
$ bin/magento setup:static-content:deploy -f
$ bin/magento cache:clean

Listed requirements

These are the details supplied in this listing. Confirm the selected release supports your Magento edition, PHP and storefront.

Magento versions listed2.4.6, 2.4.7, 2.4.8
PHP versions listed8.1, 8.2, 8.3, 8.4
Themes listedHyvä, Luma
Composer packagemage2kishan/module-order-cleanup

Read package requirements and license

Documentation

Product details and setup guidance. Check the package repository for release-specific instructions.

Delete orders from the Magento 2 admin

Magento does not ship a way to delete orders. Order Cleanup (Panth_OrderCleanup) adds a delete button to the admin order view and a mass action to the Sales > Orders grid. It is an admin only module for removing test, spam or other unwanted orders.

Deletions are permanent. Rows are removed from the sales and quote tables in one database transaction per order, and there is no undo, so back up the database before you use it on real orders.

What it adds

  • A Delete This Order button on the order view, with configurable text and colour.
  • A confirmation dialog that lists what will be removed. It can require typing the order number, and the server checks that value again.
  • A Delete Orders (Permanent) mass action with an optional confirmation and a maximum number of orders per run (50 by default). If you select more, nothing is deleted and the limit is reported.
  • Yes or No settings for deleting the order's invoices, shipments, credit memos and payment transactions. When one is No, an order that has those documents is refused.
  • An Allowed Order Statuses for Deletion list. By default only canceled, closed, on hold, pending and fraud orders can be deleted.
  • A Deletion Log grid with order number, customer name and email, grand total, status, item summary, related documents, admin user, IP address, method and time.
  • Four ACL resources for configuration, single delete, mass delete and the log.

Settings

Stores > Configuration > Panth Extensions > Order Cleanup, default scope only. The log is under Order Cleanup > Deletion Log.

Things to know before installing

  • Typing the order number is required for the order view button only, not for the mass action.
  • The deletes run directly on the database. The sales_order_delete_before and sales_order_delete_after events are dispatched, but plugins on the order repository do not run, and rows from other extensions are removed only where the database cascades.
  • Nothing is deleted automatically: there are no cron jobs, console commands or age rules.
  • The deletion log keeps customer names and emails of deleted orders until you remove it.

Requirements

  • Magento Open Source or Adobe Commerce 2.4.4 to 2.4.8.
  • PHP 8.1, 8.2, 8.3 or 8.4.
  • Panth Core (mage2kishan/module-core), installed by Composer.

Free and open source under the MIT License.

Developer notes

  • PHP namespace: Panth\OrderCleanup. Admin route front name: panth_ordercleanup.
  • Every deletion goes through Model\OrderDeleter::deleteOrder(int $orderId, string $method = 'single'): array, which returns success, message and, on success, increment_id. To hook into deletions, observe the sales_order_delete_before and sales_order_delete_after events it dispatches.
  • Controller\Adminhtml\Order\Delete accepts POST with order_id and, when typing the order ID is required, confirm_increment_id. Controller\Adminhtml\Order\MassDelete accepts POST and uses the UI mass action filter.
  • The order view button is Block\Adminhtml\Order\View\DeleteButton in the page.main.actions container. The mass action is panth_delete_orders on sales_order_grid, and Ui\Component\MassAction\DeleteAction hides it and removes its confirmation dialog according to the configuration and ACL.
  • ACL resources: Panth_OrderCleanup::config, Panth_OrderCleanup::delete_order, Panth_OrderCleanup::mass_delete and Panth_OrderCleanup::view_log.
  • Table: panth_order_deletion_log.
  • The module declares no plugins, preferences, observers or web API endpoints.
More information
Module Category Admin Tools
Best For All Sizes
Kishan Savaliya

Questions before you install?

Send me your composer.json and I will check for conflicts first. Free. Installation is +$45, custom work is quoted first.

Ask on WhatsApp