Tutorials

Add a Product List to WooCommerce’s Order Columns

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!


Our Specialities

Web Design & Development

From an idea and some notes to a fully functioning website, if you can dream it, Mitch can design and build it!

Twitch Marketing

We show you how to work with the most interesting content creators on the planet - Twitch streamers!

Social Media & Marketing

We give you the tools, training, and resources you need to get your story told on Twitter, Instagram, and more!

Brand Identity Design

A new logo, color palette, or even an entire style guide - we can help with a brand new brand (and the resources to keep your assets in line!)

Content Strategy & Creation

Want to start a podcast? A YouTube channel? A Twtich stream? Take it from an old pro - you've come to the right place!

eCommerce Consultation

Whether it's a digital service or a physical product, we can get you up and selling quickly and easily!

Community Management

Find your tribe and make them your rabid fans. Mitch can help with the technical ins-and-outs of it all!

Contact Greyhawk Digital