• Home
  • About Mitch
  • Speaking
  • Articles
  • Contact
  • Home
  • About Mitch
  • Speaking
  • Articles
  • Contact

Digital Strategist

WordPress Developer

Content Creator

Unapologetic Punk

Mitch Canter

  • X
  • Bluesky
  • GitHub
  • Twitch
  • YouTube
  • LinkedIn
Tutorials

Add a Product List to WooCommerce’s Order Columns

CMDR Mitchcraft

Reading time: 2 minutes
turned on gray laptop computer

If you’re running WooCommerce, the Orders screen is a great way to see – at a glance – what’s going on in your store.  However, there’s one thing that it absolutely doesn’t show: the products that people have ordered.

The code below changes that – it gives you a special column in your Orders screen called “Products” and shows a quantity and product name for each product a person has ordered.  Just paste this code into a site-plugin or into your functions.php file:

add_filter( 'manage_edit-shop_order_columns', 'show_product_order',15 );
function show_product_order($columns){

   //add column
   $columns['product-display'] = __( 'Products');

   return $columns;
}

add_action( 'manage_shop_order_posts_custom_column' , 'snv_custom_shop_order_column', 10, 2 );
function snv_custom_shop_order_column( $column ) {
 global $post, $woocommerce, $the_order;

    switch ( $column ) {

        case 'product-display' :
            $terms = $the_order->get_items();

          if ( is_array( $terms ) ) {
                foreach($terms as $term)
        {
        echo $term['item_meta']['_qty'][0] .' x ' . $term['name'] .'
';
        }
              } else {
                _e( 'Unable get the products', 'woocommerce' );
        }
            break;

    }
}

Let’s break it down:

The filter (“show_product_order”) adds a column to the WooCommerce Orders Admin screen.  The column will show up at the end of the other column lists.

The action (“snv_custom_shop_order_column”) adds a function to the “manage_shop_order_posts_custom_column” (whew!) hook in WooCommerce.  It then checks each order listed in the column and looks for a column field called “product-display” – which we defined in the filter above.  It then echoes the quantity and the name for each product listed.

Feel free to modify this as you wish – you can also find a Gist of this on GitHub if you’d rather see it / bookmark it there!

Code, WooCommerce, WordPress
  • WordPress for iOS: Much Improved

    WordPress for iOS: Much Improved

    Reading time: 1 minute

    I wrote a post a while back stating that the iOS app for WordPress was… lackluster, at best.  That was nearly a year-and-a-half ago, and it’s nice to see that the app has come a long way.  I downloaded it to test it recently, and I was happily surprised with what I found: Taking a…

    WordPress
  • Thursday Conversations: HTML5

    Thursday Conversations: HTML5

    Reading time: 2 minutes

    One of the best new features of 3.1 – this brings Internal Linking to the forefront, allowing you to quickly link to old posts, pages, or other content types. Admin Bar Also super important – this adds a bar to any logged in user that has commonly used functions or actions within easy reach –…

    WordPress