4

I have a bunch of test orders and I'd like to remove them. Is there a way to bulk remove all of the orders without uninstalling/installing the Ubercart module?

Obviously, I'd first backup the database with a simple drush sql-dump.

2
  • You can try flushing the orders MySQL table using phpMyAdmin or any db management tool. If you do please backup your database and test if everything is ok.
    – ANDiTKO
    Dec 28, 2011 at 7:21
  • Have you done this before ? Are you sure you don't forget some child tables like uc_order_line_items ? It won't bother Drupal to have these lines left in your tables but it's not a good advice to give.
    – tostinni
    Dec 28, 2011 at 19:23

2 Answers 2

6

I would discourage you from messing with the database unless you really know what you're doing. You should better use the API and the function uc_order_delete().

Have a look at this example script:

<?php
  include_once './includes/bootstrap.inc';
  drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

  global $user;

  if ($user->uid == 1) {
    $result = db_query("select order_id 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.";
  }
?>

Source: Delete all orders in Ubercart.

1
  • Or use this Bulk delete orders module , so you can do bulk delete from admin > store > order itself.
    – Serjas
    Nov 29, 2012 at 6:26
4

You can use a view created with the Views Bulk Operations (VBO) module to delete orders.

This module augments Views by allowing bulk operations to be executed on the displayed rows. It does so by showing a checkbox in front of each node, and adding a select box containing operations that can be applied. Drupal Core or Rules actions can be used.

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.