• 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
  • State of the Word 2023 Recap

    State of the Word 2023 Recap

    Reading time: 2 minutes

    The WordPress community was abuzz with excitement as Matt Mullenweg, WordPress’ illustrious co-founder, took to the international stage to deliver the first non-North-American “State of the Word”, live from Spain. While there was some retrospection, the theme of the event was definitively looking forward as Matt (and Matias ventura, WordPress’ lead architect) teased new features…

    WordPress
  • Using Hyperlinks Correctly in WordPress

    Using Hyperlinks Correctly in WordPress

    Reading time: 2 minutes

    Any good content marketer worth his or her salt knows the value of using links in their content. It’s a good strategy to practice – whether you’re linking internally to content you’ve written in the past or to external resources you mention in posts.  However, a lot of people overlook a small, single detail that could…

    WordPress