Woocommerce update custom order query for 3.0

I’ve got some code which outputs a list of completed orders to the [sales-list] shortcode in my functions.php. It was working perfectly before the 3.0 update of Woocommerce, but has since stopped working due to (I assume) the new CRUD classes in 3.0.

Question is: how do I adapt this to work with the new classes? Or if that isn’t the issue, what else may have changed?

Here’s the code:

/* Sales List */
function saleslist_shortcode() {
  global $woocommerce;
  $args = array(
      'post_type' => 'shop_order',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'tax_query' => array(
              'taxonomy' => 'shop_order_status',
              'field' => 'slug',
              'terms' => array(

  $loop = new WP_Query($args); ?>

  <div class="sales-list">
  while ($loop->have_posts()):
      $order_id = $loop->post->ID;
      $order    = new WC_Order($order_id); ?>
        <h6 class="mtn ptn">Order #<?php echo $order_id; ?> &mdash; <time datetime="<?php the_time('c'); ?>"><?php echo the_time('d/m/Y'); ?></time></h6>
          <table cellspacing="0" cellpadding="2">
                    <?php echo $order->email_order_items_table( array(
                        'show_sku'      => true,
                        'show_image'    => false,
                        'image_size'    => array( 32, 32 ),
                        'plain_text'    => $plain_text,
                        'sent_to_admin' => true
                    ) ); ?>
        <div style="clear:both;"></div>   
    <?php endwhile; ?>

add_shortcode( 'sales-list', 'saleslist_shortcode' );

Read more here: Woocommerce update custom order query for 3.0

Leave a Reply

Your email address will not be published. Required fields are marked *