I have a heavily customized commerce site that I have just completed and I need to hand it over to the client. It has a ton of test orders, profiles etc. How can I reset all of the orders, profiles (revisions), carts auto increments etc so that it's scrubbed and can start over?

There is a similar question asked here, but it only covers orders. How to reset the id of the orders generated by Commerce module

On a side note, I would imaging this would make a great contrib module as I would imagine many other would require this.

Note: Uninstalling and reinstalling commerce is not an option as there are a ton of other configs and commerce contrib modules already set.

  • I recently had to do this and I ended up using custom code plus the Batch API to delete the entities. It's not especially hard but my code is mixed in with a bunch of unrelated stuff that was tidied up at the same time so not ready to post here. Feb 13, 2015 at 10:43

3 Answers 3


I don't recommend truncating database tables, because you also have to consider field data / revision tables - that can get nice and tricky if you've used the same field on entities that you want to delete and on those you want to keep. There also may be other contributed modules on the site that have stored data related to these entities. Without using the API to delete these entities properly, you'll end up with this stale data laying around that may or may not cause problems later.

If I had to do this I'd either do as the other answer recommended - go through each list and use the delete links - or in the case of large data sets, I'd add Views Bulk Operations to the Views so I could delete them en masse. VBO is one of Drupal's best kept secrets - great for automating routine tasks like this.

When deleting Commerce entities, I'd start with payment transactions then orders then products and customer profiles. You need to delete both complete orders and shopping cart orders, otherwise referenced products / customer profiles will not be deletable.

  • Perfect, thanks, Ryan. What about resetting the order id, profile id (and others that i might not be aware of) back to "1"? This is especially important as I am using the order id as the charitable tax receipt and according to Canadian government standards (CRA), all receipt numbers need to be accounted for and consecutive. Feb 12, 2013 at 16:50
  • Mmm, yeah, since we're trying to avoid truncating, the idea would be to either use phpMyAdmin's "Operations" tab for the table and adjust the auto_increment value there or just use the direct SQL query: ALTER TABLE table_name AUTO_INCREMENT = 0 Feb 12, 2013 at 16:56
  • 2
    It looks like this is opening up a whole can of worms. As you mentioned, if you are sharing fields across entities and other modules relying on this info then you're hooped. As a word of caution for anyone reading this. Make some dummy products and transaction on a test site, rather than the one you are going to hand over to the client. Trying to get rid of them after the fact and resetting commerce is a pain. Feb 15, 2013 at 4:57

Just contributed a module called Commerce Reset.

This module will allow you to.

  1. Delete orders and reset order number.
  2. Delete payment transactions.
  3. Delete customer profiles.
  4. Delete product variations

Check it out here Commerce reset

  • I just used this - worked great
    – Dalmaz
    Nov 13, 2015 at 22:00

I recently ran into a scenario like this. I am not aware of any module that can do this so I think you might have the same 2 options that I did:

  • Manually go through each section, orders, profiles, etc., and delete the entries. Might not be a viable solution if you have thousands on entries.

  • Truncate the appropriate databases using SQL. I would backup the database first before you try this but the schema is relatively easy to figure out if you either profile the database or browse through the Commerce code base.

I personally went with the second option and it worked out quite nicely for me.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.