Search the site:

How WooCommerce order numbers are generated

You may have often wondered why, sometimes, WooCommerce order numbers don’t appear to be sequential. Order numbers being in order is something most site owners would expect to see, and for those seeing this for the first time, these out-of-sequence order numbers can be slightly misleading, causing one to think that some orders are missing or haven’t been updated in the list. In this post, we will explore why these numbers are not in order by understanding how exactly WooCommerce order numbers are generated. We will also see how we can assign sequential or custom order numbers.

how WooCommerce order numbers are generated - Default WooCommerce Order Numbers Screenshot
WooCommerce Order Numbers

WooCommerce is a WordPress plugin, and WordPress stores everything as a record in the wp_posts table in the database – whether it is a blog post, a page, a product, an image or an order. The default post types as well as custom post types are all stored in this wp_posts table. Thus, each time an order is created, a new record for it gets added in wp_posts table. All records in this table have a unique ID, and the order number is the same as this unique ID.

how WooCommerce order numbers are generated - The wp_posts table
The wp_posts table

Why do sometimes order numbers appear to be in sequence?

If, in between orders, there have been no new product additions, image/attachment uploads or no new page additions, then the order numbers may appear in sequence, as illustrated in the screenshot where order numbers 112, 113 and 114 are in sequence:

how WooCommerce order numbers are generated - Orders in Sequence


But, if a product is added to your store in between orders, this will also be considered as a post and a record for it will be created and assigned the next unique ID in sequence. If the product has an image (which it will, in most cases), then this image will also have its own record and ID. The same applies to new pages. This can cause the order numbers to be non-sequential.

shop_order Post Type

The post_type column in the wp_posts table denotes the type of post the record refers to. As you can see in the following screenshot, this takes different values such as shop_order, page, product, post, attachment and so on, depending on whether it’s an order, a page, a product, a post, an attachment (image) etc. Of these, ‘page’, ‘post’ and ‘attachment’ are default post types, while ‘shop_order’ and ‘product’ are custom post types. Click here to know more about WordPress post types.

how WooCommerce order numbers are generated - The post_type column in the wp_posts table
The post_type column

The process of adding new features thus becomes simple through the use of custom post types.

How to assign custom or sequential order numbers

Sometimes, as a store owner, you may want your order numbers to appear in a sequence. Sequential order numbers are useful in many instances, a simple example being when you want to confirm that no order has gone missing. Sequential order numbers are of paramount importance when it comes to accounting. In many countries, having sequential invoice numbers is mandatory. Having order numbers that are in sequence can thus be a necessity in such cases. There are many ways to achieve this requirement of order numbers appearing sequentially, and we offer a plugin for the same. This plugin is available in both free and paid versions, with different features in each:

  • Custom Order Numbers For WooCommerce- Free: With this plugin, you can assign custom order numbers. This includes sequential order numbers, random auto-generated order numbers (using a hash algorithm) or just the default order IDs. The sequence of these numbers can be reset either on a weekly basis, or on a monthly or yearly basis. With this plugin, you can also add a prefix to the order numbers, renumerate or recount existing orders, enable order tracking and admin order search by customer number. All this can be done through an interface accessible through the dashboard under WooCommerce->Settings WooCommerce order numbers are generated - Custom Order Numbers for WooCommerce Plugin Screenshot
    how WooCommerce order numbers are generated - Custom Order Numbers for WooCommerce Plugin Screenshot
  • Custom Order Numbers For WooCommerce- Premium: The premium version of this plugin offers the features offered by the free version and much more. With this plugin, you can even add a custom template for the order number consisting of a prefix, suffix, date, number etc. You can also add a suffix to each order, consisting of tags or dates.
Browse more in: WooCommerce How Tos, WooCommerce Tutorials
Notify of

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

Inline Feedbacks
View all comments
Narender Singh
1 year ago

If I understand correctly, if I don’t update anything, then the order numbers should be in sequence? However mine are just random. They skip many numbers. Like from 10003 to 10035 and then to 10044. I’m confused about how they are being generated. Any clues there?

Narender Singh
1 year ago
Reply to  Anubha Bhat

That’s where the clash is. I have a dedicated install of WordPress for the shop. So, there are no new posts, pages, images or other content being added. Other than some reviews which are ocassional and new products (every few months). And I’m sure there are no reviews between several orders, they still jump the sequences. So, it is kind of weird to see the random order IDs. I don’t necessarily have a problem with them. I just wanted to find out why that happens. I’m not sure if your explanation fits there because mine is random without those post… Read more »

Jelle Wielsma
Jelle Wielsma
1 year ago
Reply to  Narender Singh

Not only new posts or pages generate new ID’s, also hidden entries like concept posts, revisions, media attachments, log entries or anything else that is stored as a post type item of some sort. Pretty sure this is why your order ID’s are seemingly random.

Marek Peschl
Marek Peschl
1 year ago

Hello, thanx for the plugin! However there’s a problem that I can’t figure out. When I use custom order numbers I can’t find the orders through the search input in products page in backend. It find nothing even if I checked “Enable order admin search by custom number”. Does anyone got a same problem? Thanx, Marek

10 months ago

Can i make somehow consequence progressive numbers only by processing status?

Niall Flynn
2 months ago

Nice post, got asked this today after about 10 years of using WC, I had an idea but this post is succinct, cheers!

1 month ago

Hello, I am using the plugin “Custom Order Numbers For WooCommerce- Free” and it works for me. But I wanted to ask how I can locate the new custom order numbers in the database. I can find the old order numbers in the wp_posts table, but I can not locate the new custom sequential order numbers. Can any of you help me?

from purchased

Subscribe for more offers

Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins and 50% OFF on Bundles
Would love your thoughts, please comment.x