How to add a sequence number to WooCommerce order

Why are WooCommerce order numbers not sequential?

WooCommerce orders are stored into wp_posts table together with almost everything you do on your WordPress website. Posts, pages, drafts, forms and other are all stored in the same table and they share the same sequence number.

This is the reason you see a gap between order numbers, like some order is missing. It would be much more convenient to have these numbers in a sequence so when you filter the orders, you can quickly tell how many orders are filtered out.

How do I set order numbers in WooCommerce?

Since we can’t rely on the id of the wp_posts table, we have to add a new order number sequence and keep a track of it. This is not hard to do with a code snippet but in this article I will use 2 free plugins.

Plugin to add and track custom order numbers in WooCommerce orders
Plugin to add or change admin columns

Sequential Order Number for WooCommerce

Sequential Order Number for WooCommerce plugin is free and easy to set-up. There is a paid version but you don’t need it to add a simple number sequence.

After you install and activate the plugin, go to WooCommerce settings and open “Sequential Order Number”. You can use many different sequences but if you just want a simple numbered sequence then configure it like I did on the image below.

The simple numbered sequence configuration

The plugin will change the number in the first “Order” column, instead of post_id, there will be a custom sequence.

Custom sequence number in the “Order” column

Admin Columns

You can leave it like this but I would like to show a sequence number in a separate column, like this:

Custom WooCommerce order sequence in a separate column

There are many ways to do this but the simplest way is to use a plugin. I am using “Admin Columns”, free version.

After you install and activate the plugin, go to your orders page and click the settings button

Admin Columns settings button

Then click the “+ Add Column button”

Add a new admin column to WooCommerce orders

Select the “Custom Field” type and “_order_number” in the “Field” dropdown. “Label” can be anything, this is the name of the column above the WooCommerce orders list. I will also configure “Field Type” as “Number” but this is not that important because we use this column to sort or filter orders. This can be done in a paid version so if you really need it, you can purchase the pro license or create a code snippet to allow the sorting and filtering.

Custom admin column configuration

Summary

Most WordPress plugins use a wp_posts table to store their data. This is a good practice as it makes easier for different plugins to work together on the same data. But this means we can’t use the id of the wp_posts table as a sequence number of the WooCommerce orders. We have to create our own sequence that will be used only for WooCommerce orders and not shared between the posts, revisions, pages etc. Sequential Order Number for WooCommerce is a plugin that does exactly that. You can configure the sequence in many different ways but even a simple numbered sequence is much better than the default WooCommerce functionality. Free version of the plugin is a good option for the most users.

If you want to display the newly created sequence in a separate column, you can use the Admin Columns plugin. It’s a very simple to use and fast to configure but unfortunately it doesn’t allow sorting and filtering in the free version. Still, it’s a great plugin if you only want to see the value and don’t want to spend a lot of time configuring it.

Leave a Comment