• 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
  • Better Know a WordPress Tag: ‘siteurl’

    Better Know a WordPress Tag: ‘siteurl’

    Reading time: 1 minute

    When you’re working on a development site it’s hard to set things up correctly because you know you’re going to change the site, and putting in elements that are more than likely “stationary”, such as links, will have to be changed, and that causes un-necessary headache when it comes time to move the site live. …

    WordPress
  • My Take on WordPress 3.8

    My Take on WordPress 3.8

    Reading time: 3 minutes

    WordPress 3.8 came out just a few days ago, and I jumped at the chance to install it on as many of my blogs as I could manage.  This was one of the most anticipated updates in years – and with good reason.  It was a complete overhaul of the admin interface and added quite…

    WordPress