How to add custom columns to WooCommerce orders table in WordPress backend

Adding custom cols to the orders table can be very useful for shop managers and admins. If you use some kind of invoice or shipping plugin, you probably don’t want to click in each order to see if there is already a shipping label or an invoice created. So what you want to do is displaying this information directly in the orders overview table. In this example I will create a new column to where I want to show the customers order note if there is one available. At first you have to define the columns Header by adding this code snippet to your (child-)themes functions.php:

add_filter( 'manage_edit-shop_order_columns', 'wc_new_order_column' );
function wc_new_order_column( $columns ) {
  $columns['order_note'] = 'Order Note';
  return $columns;
}

After that you have to define what kind of content you want to display in each orders new column:

add_action( 'manage_shop_order_posts_custom_column', 'tk_add_order_note_content' );
function tk_add_order_note_content($column) {

  global $post;
  
  $order_id = $post->ID;

    $order = wc_get_order( $order_id );
    $customer_note = $order ->get_customer_note();

  
  if( $column == 'order_note' ) {
    echo $customer_note;
  }

}

That’s it. You’ll now see the customers order notes directly in the orders table.

Leave a Comment

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