Posted on

WooCommerce: Add Column to Orders Table @ WP Dashboard

The WooCommerce Orders Table, which can be found under WP Dashboard > WooCommerce > Orders, provides us with 7 default columns: Order – Date – Status – Billing – Ship to – Total – Actions. This is used by shop managers to have an overview of all orders, before eventually clicking on a specific one.

So the question is: how can we display additional columns to that same orders table, so that we can immediately visualize an order custom field, a specific product contained in the order, or anything order-related that can be “calculated” once we have access to the $order variable?

Display an additional columns in the Orders Table @ WooCommerce Dashboard

PHP Snippet: Display Custom Column @ WooCommerce Admin Orders Table


/**
 * @snippet       Add Column to Orders Table (e.g. Billing Country) - WooCommerce
 * @how-to        Watch tutorial @ https://businessbloomer.com/?p=19055
 * @sourcecode    https://businessbloomer.com/?p=78723
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.4.5
 */

add_filter( 'manage_edit-shop_order_columns', 'bbloomer_add_new_order_admin_list_column' );

function bbloomer_add_new_order_admin_list_column( $columns ) {
    $columns['billing_country'] = 'Country';
    return $columns;
}

add_action( 'manage_shop_order_posts_custom_column', 'bbloomer_add_new_order_admin_list_column_content' );

function bbloomer_add_new_order_admin_list_column_content( $column ) {
  
    global $post;

    if ( 'billing_country' === $column ) {

        $order = wc_get_order( $post->ID );
        echo $order->get_billing_country();
	  
    }
}

Where to add this code?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such delicate files - if you need more guidance, please take a look at my free WooCommerce Customization video tutorial.

Does this snippet still work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free videos, tutorials and tips!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP
  • woocommerce-customize-shop-page-PHP
  • woocommerce-advanced-customization
  • how-to-edit-woocommerce-cart
  • woocommerce-customize-checkout-page-PHP
  • woocommerce-email-customization
  • woocommerce-conditional-logic

Rodolfo Melogli

Author, WooCommerce expert, WordCamp speaker and Internet marketer, Rodolfo Melogli has worked as a WooCommerce freelancer since 2011. He helps entrepreneurs and developers overcome their WooCommerce nightmares :) Rodolfo is the organiser of WordCamp Dublin, the Dublin WooCommerce Meetup, the Dublin Ecommerce Meetup and the Dublin WordPress Meetup. He enjoys interacting with people, travelling and chasing tennis & soccer balls. Of course, he loves pizza too.

12 thoughts on “WooCommerce: Add Column to Orders Table @ WP Dashboard

  1. Hi,

    I have some custom checkout fields I would like to show as columns, how do I need to change your code to work for my use case?

    I tired it as it is but only seems to work for standard checkout fields like country, state, first name, etc.

    Btw, thank you for the snippet 🙂

    1. Hello there, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R

  2. Hi Rodolfo,
    Perfect, I added my code for get_total_tax(). It’s helpful for to do my accounting (with Dougs), not oblige to open each order for check if I must indicate if it’s taxed or not. But right now I’ve no idea how to add the Stripe fee in a column. I’m going to see that later. Unless you have an idea 🙂
    Thanks a lot again for your tips.
    Rémi from France.

    1. Excellent! I’m sure you’ll figure out the Stripe thing as well 🙂

  3. Hi Rodolfo,
    This is again a great article, One of my friends is using this method. It really helps them.

    1. Cool 🙂

  4. Hi Rodolfo,

    Thanks for yet another great Woo snippet! Can this be used to display which coupon code was used for each order, if any?

    Thanks!
    -Steve

    1. Hey Steve – thanks so much for your comment! Positive, the get_used_coupons() function should help 🙂

  5. Could I add a column for the product photo?

    1. Hello Carole – thanks so much for your comment! Of course – as long as orders have max 1 product or if you just want to show the first product 🙂

  6. Greetings Rodolfo !
    Thanks for your tips !
    I’m going to try it this week. That will be helpful for me, I wish to see Tax, Stripe fee,.. for to do my accounting without open each order. I will se if I can with your tips.
    (However, maybe I can do that by export all order in a xls table)
    Thanks
    Rémi

    1. Rémi – thanks so much for your comment! Good luck 🙂

Questions? Feedback? Support? Leave your Comment Now!
If you're writing code, please wrap it between: [php] code_here [/php]

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.