title: Bulk update order status in WooCommerce every XXX hours
body: <ul>
  <li>I'm trying to programatically update all order status every 6 hours.</li>
  <li>There are 3 custom status after 'complete', each to be updated in sequence every 6 hours.</li>
  <li>I created a cron to run every 6 hours calling function 'auto_update_orders'.</li>
  </ul>
  
  <p>Would it be better to do it this way or a direct SQL query? If done via SQL query, would the automatic emails for the custom statuses still be sent out?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>function auto_update_orders() {
  
  $args = array(
      'post_type'         =&gt; 'shop_order',
      'posts_per_page'    =&gt; -1,
      'post_status'       =&gt; 'complete',
  );
  
  $orderList = get_posts($args);
  
  foreach ($orderList as $orderPost) {
  
      $order = new WC_Order($orderPost-&gt;ID);
  
      if ( $order-&gt;has_status( 'completed' ) ) {
          $order-&gt;update_status( 'inprogress2' );
      }
      elseif ( $order-&gt;has_status( 'inprogress2' ) ) {
          $order-&gt;update_status( 'inprogress3' );
      }
      elseif ( $order-&gt;has_status( 'inprogress3' ) ) {
          $order-&gt;update_status( 'ready' );
      }
      else {
          return;
      }
  
  }</code></pre>
  </div>
  </div>
  </p>