Commerce Order Cleanup

Allows to cleanup the orders by various order properties like last changed, status.

Things to consider

  1. Make sure there is a periodic archive process for DB (or just order details) is in place(why?).
  2. Consider using Commerce Cart Expiration if the requirement is just to clean the orders that are in cart status.
  3. Think backup/archive would be a great addition? help to get #2337337: Support archive before delete in

Drush integration

Currently this module provides list of Drush commands to view, delete the orders. See drush coc --help for more details.

Version 7.x-1.1

Allows to delete any order type, status and changed date(excluding global max date).


// Delete all cart orders that were changed on or before default changed(set by commerce_order_cleanup_max_date variable)"
drush coc

// Deletes all the orders in status 'checkout_complete' and changed on or before default changed
drush coc --status="checkout_complete"

//Deletes all the orders that are changed on or before 2 months before.
drush coc --changed="-2 months"

// Deletes all the orders that have 'product' line item and changed on or before 01-01-2014 00:00:00
drush coc --type="product"  --changed=138853440

Version 7.x-1.2

As this is a delete operation and can not be undone without backup/restore, made the deletion more strict and expects all filters.
1. Max deletion date per line item type.
2. All 3 filter types (status, changed and line item type) are mandatory.

// List all the orders have line item of type product with status 'checkout_complete' that are changed on or before 2 months. Pass '-y' to delete.
drush coc product --status=checkout_complete --changed="-2 months"

Related module

Commerce Cart Expiration allows to delete orders in cart.

Want to help?

You can help by reporting issues at the issue queue or at Github and issuing patch/pull request.

Supporting organizations: 
sponsored initial development.

Project Information

Downloads