I have created so many testing orders in the Ubercart during the development. So before i migrate the site to production, i have to clear all the testing orders. This could be done by deleting the order one by one through the View orders page.
But i got more than 100 testing orders and obviously the above method is not clever enough.
So i created the following delete_all_orders.php in the <drupal_root> folder
delete_all_orders.php
<?php include_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); global $user; if ($user->uid == 1) { $result = db_query("select * from uc_orders"); while($row = db_fetch_object($result)){ //# uncomment below to view an order and exit //# usefull to write a query to only delete certain orders //print_r($row); //exit; print "deleting order $row->order_id\n"; uc_order_delete($row->order_id); // comment this out for testing } } else { print "Only Administrater could deleter orders."; } ?>
Now you can delete all the orders using the administrator account to access the following URL.
Done =)
Reference: delete all orders
Hey, thanks for this, handy! 🙂
LikeLike
you are welcome =)
LikeLike
FAIL!!!!!
Would like to remove all of the test orders from a Ubercart database by using the empty table command in phpMyAdmin. Are the following tables the correct ones for this application? Or are there some that were missed? (Uber 1.6 – Drupal 5.12)
1) uc_orders
2) uc_order_comments
3) uc_order_admin_comments
4) uc_order_log
5) uc_order_products
6) sequences – change uc_orders_order_id back to 0
And backup the database for insurance.
LikeLike
The solution in this blog post is for Drupal 6 only. I am not sure how to do it in D5.
LikeLike
I’ve been updating an old D6 site and I’d just like to say, this worked perfectly for me. Appreciate the snippet!
LikeLike
Good to know that i could help. =D
LikeLike