How to cancel and delete order?

Hi, we are pretty new to Commerce. Please be nice :wink:

  1. How can an order be canceled (=change state) via Commerce GUI inside the MODX Manager?

  2. How can an order be deleted (=remove it totally)? (Only by directly manipulating the database?)


Hey @webaff, hope you’re having fun learning Commerce :slight_smile:

To add an option to cancel an order, create a new “Cancelled” status assigned to the Cancelled state (if it’s not already there). Then create a Status Change from the Processing status to the Cancelled status. At that point you can change the status of an order to cancelled.

If that sounds like abracadabra, please take a look at the status documentation:

It’s not possible (and most likely never will be, at least not in the core) to completely remove orders. For accounting purposes it’s important that the data is accurate, complete, and sequential, and that can’t be the case if orders can be removed.

If you’re looking to remove test data before going live: that’s not needed. When enabling live mode, all test orders and transactions are automatically hidden and you essentially start with a clean slate.

If that’s not enough, then yes, directly manipulating the database is a possibility, but I do strongly recommend against that. It’s a potential can of worms. Related data is spread across different tables and if you forget to wipe one thing, that may come back to haunt you later when actual customers start making purchases. You’ll need to go through all commerce_ prefixed tables one-by-one to make sure it’s all truncated properly. (Also, depending on what payment provider you use, you may run into issues later where it refuses a transaction because it already saw the transaction ID before.)

Hi Mark, thank you for your reply.

@1.: Done.

@2.: Your answer and implementation makes totally sense to me. But unfortunately we went to live mode too early. Now we have about 20 test orders that we want to get rid of before going public. I will check with the client if we can leave them in the system.