I am trying to find an admin page where I can delete all test payment transactions happened on drupal commerce, but could not find it.Need to no if my following plan will create any referential integrity issue after cleanup.

  1. From orders page clean all test orders.

  2. Manually clean the database tables 'commerce_payment_transaction' and 'commerce_payment_transaction_revision' and then using db API clean payment transaction table using

    db_truncate('commerce_payment_transaction'); db_truncate('commerce_payment_transaction_revision');

  3. Clean up all tested customer profiles from admin page for the same using bulk operation.

  4. Clean up test users created with the checkout process.

  5. Truncate orders table to start with order id , using again following code.



  • Could you also specify what exactly you like to preserve?
    – znerol
    Jan 16, 2014 at 8:18
  • I just want to clean up every test data without creating any issue on the site after cleanup
    – arpitr
    Jan 16, 2014 at 8:59
  • 1
    Truncating entity and field tables is never a good idea, far better to load up the order IDs and run them through commerce_order_delete()
    – Clive
    Jan 16, 2014 at 9:26
  • @Clive I am deleting the orders using views bulk operation but I am seeing test data is still there in payment tables so using commerce_order_delete() will help here?
    – arpitr
    Jan 16, 2014 at 9:28
  • Oh right, if it's orphaned data then yes you might need to get rid of it manually
    – Clive
    Jan 16, 2014 at 9:29

2 Answers 2


The short answer is there is no such page. What you're attempting to build with VBO should work well, but currently there is no automatic deletion of payment transactions when orders are deleted. It's questionable whether or not we actually want that to be the default behavior. However, if you're just using VBO driven by custom rules components, you should be able to load any payment transaction referencing the order to be deleted and delete them from within the same rule. Using commerce_order_delete() will not delete payment transactions; for that you'd need commerce_payment_transaction_delete().


So using just views and listing commerce_payment_transaction and deleting them will not work? I tried that and cant delete them. What also happened is that I deleted all orders first and then transactions remained in system, so only way I see is to delete them directly in DB.

  • In the VBO execute arbitrary php code and use the snippet below. commerce_payment_transaction_delete($context['commerce_payment_transaction']->transaction_id);
    – Kevin Siji
    Jun 25, 2015 at 8:00

Your Answer

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

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