I am trying to bulk update lots of Woocomerce orders (Approx 8000) from processing to Completed. Using the bulk editor I just get an error trying to select so many and change the status. So I made the following query but had to limit the returned results to 100 and I'm only returning IDs to speed it up, any more and the serer would 500 error. But even this is taking ages to execute. We are running on an Azure server.

Is there a more efficient way to do this? Thanks:

     $args = array(
       'limit' => 100,
       'return' => 'ids',
       'status' => 'processing',
       'orderby' => 'ID',
       'order' => 'ASC',

      $query = new WC_Order_Query( $args );

      $orders = $query->get_orders();

      foreach( $orders as $order_id ) {
        if ($order_id <= 18500) {
            $order = new WC_Order($order_id);
            if (!empty($order)) {
               $order->update_status( 'completed' );
  • in the query you can filter to select only ID <= 18500 and status != "completed". then you just have to refresh the page 80 times to treat them all (and in the darkness bind them). – Kaperto Nov 17 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.