This article discusses how to show and add an additional column in the admin of WooCommerce Orders page. We will also look at showing the data from the custom field and how to make the new column sortable.
The WooCommerce orders admin page looks as shown below:
There are a total of 8 columns that are displayed by default in WooCommerce orders page.
If you are already aware about what each column displays, then skip to the section right after it.
Understanding the default columns on Orders page
Column Number 1: Status
This column on the WooCommerce orders admin page shows you the status of the orders that have been placed by the customers on your WooCommerce store.
The status could be either Pending Payment, Processing, On hold, Completed, Cancelled, Refunded or Failed & it is denoted by different icons.
Column Number 2: Order
The Order column shows the order #, customer name & customer email address.
Column Number 3: Ship To
The next column on the WooCommerce orders admin page is the Ship To column. This column shows the shipping details as were entered in the “Shipping Address” fields on checkout page.
Column Number 4: Customer Message
As the name suggests, the Customer Message column shows you the message that the customer has sent you pertaining to the order. This corresponds to the Order Notes field on the checkout page.
Column Number 5: Order Notes
Although this column is titled as Order Notes, it is not to be confused with the Order Notes field on the checkout page. These are notes that typically indicate the order status changes, or any other logs related to it.
Column Number 6: Date
This column shows you the date that the order had been placed.
Column Number 7: Totals
The Totals column shows the total order amount along with the payment method.
Column Number 8: Action
The Action column allows you to do actions like mark the order as Complete or view the order details.
Adding new columns to the Orders Page
Instead of writing the code in functions.php file or anywhere else, it’s best if you create a plugin for this.
Step 1: Add the following lines to your plugin file
For this, the new columns: MY_COLUMN_1_TITLE and MY_COLUMN_2_TITLE are going to be added to the WooCommerce orders admin page.
A few things here:
i. The add filter line of code calls into action the function to create new columns arrays in the admin orders page automatically.
ii. “MY_COLUMN_ID_1” – This function is for the new first column ID (identification). Creates new column ID.
iii. “MY_COLUMN_ID_2” – This function is the new second column ID (identification). Creates new column ID.
iv. 2 New columns will be created that is “MY_COLUMN_1_TITLE” and “MY_COLUMN_2_TITLE” you can use your own titles here that you want to appear in the WooCommerce Orders page.
v. If you just want to add one new column just delete the other column and if you want to add other columns let say 4 or ten just add different lines of codes under the same.
If you go to the WooCommerce orders admin page and you will see that the changes have taken place and two new columns have been added, that is “MY_COLUMN_1_TITLE” and “MY_COLUMN_2_TITLE” just in between Totals and Actions columns as shown below:
Step 2
Next, we are going to look at how to make those new columns sortable, that is how to sort the items in the just created new columns on WooCommerce orders admin page.
Add the below lines of code in your plugin file. Preferably, you can paste the given lines of codes just below the other lines of codes that we discussed earlier.
The new layout after adding the above lines of code.
Sorting the new column items means being able to arrange the items that will be displayed on those new columns. The new column items change into links to enable you easily sort the items in those new columns.
NOTE: There is normally a triangle icon that will appear and become available on sorting attributes.
Increase WooCommerce Store Sales
"It’s interesting to see how much WooCommerce Abandoned Cart Pro has increased sales for high value products. I would have expected the plugin to increase sales for low value products that customers don’t mind whether or not they purchase (e.g. food), but I have been more surprised to see the difference it can make for products that require such a big buying decision." - Katie Keith, Operations Director at Barn2 Media
Step 3
Lastly, we are going to look at how to make those created new columns have custom fields. The custom fields will be useful in allowing the store admin to add additional information on the various orders that have been made by the customer.
You can do that by adding the below lines of codes in your new plugin file:
Here we are assuming that you have created the custom fields that are storing the values in the above mentioned post meta records:MY_COLUMN_1_POST_META_ID & MY_COLUMN_2_POST_META_ID.
That’s it. Doing the above will add & show your new columns on the WooCommerce Orders page.
We have used this same logic in the Order Delivery Date plugin. We added a new column in the plugin that shows the Delivery Date & time on the Orders page.
This is how the column appears:
As you can see, the Delivery Date is also sortable.
Hi Thanks for your sharing. Is it possible to show the total orders under that email address in new column? Thanks.
Hi Robert, It is possible to show total orders under that email. You can run this query below:
$query = “SELECT count(p.ID) AS orders_count, pm.meta_value as billing_email FROM wp_posts p
LEFT JOIN wp_postmeta pm ON p.ID = pm.post_id
WHERE post_type = ‘shop_order’ AND pm.meta_key = ‘_billing_email’
AND pm.meta_value = ‘$email’
GROUP BY billing_email”
This will give you number of orders for each email address specified with $email .
Hi Vishal,
Thanks a lot for this tuto..
I try to add a column with the “total_tax” of the order.
I found this API and name here : https://woocommerce.github.io/woocommerce-rest-api-docs/#order-properties
But I don’t know how to add this item. I tried a lot of things.. but without success !
Thanks for your help.. if you have time.. 😉
Rémi
Hi Remi,
Is there a specific reason you are wanting to use the API to fetch this column? I can check on this & get back to you as to how to add the Total tax as a column.
Hi, thanks you very much for the post! I’m having the following problem: the values of the custom fields is showing as “Array” for all orders. I created the fields using Advanced Custom Fields and replaced your “MY_COLUMN_1_POST_META_ID” with the custom field name. My code looks like this: add_filter( 'manage_edit-shop_order_columns', 'my_columns_fn' ); function my_columns_fn( $columns ) { $new_columns = ( is_array( $columns ) ) ? $columns : array(); unset( $new_columns[ 'order_actions' ] ); //edit this for your column(s) //all of your columns will be added before the actions column $new_columns['fecha_horneada'] = 'Fecha Horneada'; $new_columns['encargado'] = 'Encargado'; //stop editing $new_columns[ 'order_actions'… Read more »
Hi Camilo, Please try to change the 2 echo statements in the my_columns_value_fn().
Replace echo statement for First column with:
echo ( isset( $data[ 'fecha_horneada_data' ][ 0] ) ? $data[ 'fecha_horneada_data' ][ 0 ] : '' );
Replace echo statement for Second column with:
echo ( isset( $data[ 'encargado_data' ][ 0 ] ) ? $data[ 'encargado_data' ][ 0 ] : '' );
Let me know.
Hey Vishal, thanks for the reply! I should’ve thought about that, it worked 🙂 thank you very much for the help.
That’s great. I will update the example to reflect the same. 🙂
I added the columns via “snippet”. However, I don’t know how to get data to populate inside of those columns. I added a custom field (additional_charter) using a plugin called “Woo Checkout Field Editor Pro”. Can you help me populate this custom field data into the new column?
Hi Matt, You could consult a developer to do this for you if it’s not working after following the steps mentioned above.
this plugin do what you want : https://codecanyon.net/item/woocommerce-admin-columns-addon/20673609?ref=frzr