Home » WooCommerce: Add Column to Orders Table @ WP Dashboard

WooCommerce: Add Column to Orders Table @ WP Dashboard

by Tutor Aspire

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        Get tutoraspire.com FREE
 * @sourcecode    https://tutoraspire.com/?p=78723
 * @author        Tutor Aspire
 * @compatible    WooCommerce 3.4.5
 */

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

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

add_action( 'manage_shop_order_posts_custom_column', 'tutoraspire_add_new_order_admin_list_column_content' );

function tutoraspire_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();
  
    }
}

You may also like