Why WooCommerce Order Numbers Are out of Order

Out of Order WooCommerce Order Numbers

22, 23, 25, 39, 40 – What!? Why are my order numbers out of order? If you've used WordPress before you might know that posts, pages, and media files have IDs that aren't necessarily in order. The first one might be 20 and the next might be 43. WooCommerce uses the same ID system to create the order number which is why they're out of order.

For your average marketing website this isn't a big deal since you rarely need that number. In the e-commerce world with accounting software, drop shippers, & reports it makes a lot more sense to have consecutive order numbers. The good news is that this is really easy to do with a plugin.

Why The Order Numbers Are out of Order

First it's important to know why all of these IDs are out of order in the first place. WordPress saves everything as a post. So pages are posts, media files are posts, products are posts, orders are posts, and posts are posts. This makes it really easy for developers to interact with the database since everything uses a similar format. All of these posts (media, pages, posts, etc) use the same database table and because of that they can't share the same ID. If you want to have a consecutive order number then you have to save a bit of extra data in the database.

The design pattern behind WooCommerce is to try to stay as lean as possible and give people the ability to extend or add onto the existing functionality. If you don't need sequential order numbers then there's no point in storing all of this extra information. WooCommerce leaves this up to store manager to decide if it's necessary.

How to Make the Order Numbers Sequential

Any plugin developer can add a bit of extra data to the orders to make sure they're in order. In fact there's already an excellent plugin, WooCommerce Sequential Order Numbers, by the SkyVerge team available for free on WordPress.org. They even have a premium version with a few extra features like the ability to add a prefix ex. MyStore so your order numbers would look like MyStore001, MyStore002, etc.

Happy sequential order numbers!

More Commonly Asked WooCommerce Questions in My Book

If you want to learn more about the commonly asked WooCommerce questions I suggest you take a look at my book. It isn't out yet but you can signup for the mailing list and get a discount when it comes out.

22 thoughts on “Why WooCommerce Order Numbers Are out of Order

  1. Good stuff – thanks!

  2. Good to know. Thanks!

  3. Something to keep in mind is that Sequential Order Numbers doesn’t actually change the order/post number, it creates a new field and populates it with the new number.

    This works to change how your order numbers appear in some places in WooCommerce, but most other plugins use the unaltered “core” order number. I’m personally running across this with the Authorize.net plugin and a plugin that generates FedEx / UPS labels. I’ve seen it referenced on a Bitpay blog, too. In case it isn’t obvious, this is a problem because your WooCommerce invoice will show one order number, while another is recorded on the Authorize.net and FedEx records.

    Unfortunately, I don’t have a good solution, but I thought I’d at least throw it out there so folks don’t charge in blindly.

    • Hey Donald – thanks for sharing this.

      Are you using the official WooThemes plugins? There should be hooks in WooCommerce Sequential Order numbers that allow plugins to use the sequential order number instead of the post ID.

  4. thanks for this really helped as i was scratching my head wondering why my first order was #93

    • Per plugin installation notes: “No configuration needed! Order numbers will continue sequentially from the current highest order number, or from 1 if no orders have been placed yet.”

  5. Thank you for sharing this post Patrick…still wondering though why is that the orders are not in sequence even if I haven’t added any posts, products, pages… Anything I’ve missed out completely?
    Thank you very much!

    • Hey Larissa,
      PostID increment as well with revision, autosave, menu item etc…
      Now you may figure out how ‘sensible’ is the “post”ID increment 😉

  6. Nope, it’s definitely 404.

  7. Hi, Just wondering if clicking the WC ‘Re-Order’ button after an item has completed will cause woocommerce to use the same Order ID for the next item?

    • No it won’t. As mentioned in the article, all new WordPress entries (pages, posts, media items, wc products, wc ORDERS, revisions, menu items, even autosaves) get a unique ID assigned (auto-incremented by +1). What ‘re-ordering’ does is to simply insert an identical list of (previously ordered) items, into a new order. Therefore, re-orders also get a unique / automatically incremented ID assigned within the particular WordPress installation.

  8. what about orders which are not successful due to glitches or canclled orders?
    1. you are buying over the phone, when you lose internet connectivity
    2. you change your mind at the payment gateway page

    I’ve seen these orders stay in the my orders page and if you try to initiate a re-order from there, you get the same ID, which is rejected by the payment gateway

    • It doesn’t matter. As long as a new WP record of any kind has been created, it must have a unique ID. It cannot be any other way since WP queries the DB for data based on the record’s ID. If more than one ID’s existed for a certain record, then the whole of WP simply would not work properly.

  9. Just so everyone is aware, having non sequential transactions is a way to stop auth attacks on your site. Please do not use sequential order numbers if you have users that have login information or any data stored on your site.

    • Sequential order numbers use post meta to determine the order number. They’re not post IDs. If they were post IDs you are giving away some information to potential hackers. But there are no known issues with sequential order numbers.

  10. Heh, I was thinking the same thing, I’m glad I’ve found your post, I can sleep better now. And yeah.. it makes perfect sense! : )

  11. I downloaded WooCommerce Edit Order Numbers by SellWithWP and change the numbers from 13716 to 1456134000. But every time a NEW order comes in, the customers order number is 13717, etc. Then I have to change to my custom number again.
    Is that the way it should be or am I using the wrong plugin?

    Thanks

  12. Hi Patrick,

    We used “WooCommerce Sequential Order Numbers Pro ” to sequence the order number, So when customer makes order the order id sequence number works, where as when we go see on vendor the order number is different and the number is not in sequence, when I check that number it takes me to customer order number.

    We are looking for solution where the customer order number and vendor order number should be sequence, buy that way when customer calls the support center they are going t provide with order number they while order, but vendor cannot find as the have order number in non sequectional.

    We need your advice on the same.

  13. Hi, there is an incompatibility between WooCommerce Sequential Order Numbers & Boxtal (shipping method). Please what happen if I deactivate the WooCommerce Sequential Order Numbers plugin ?

  14. Very Helpful and Informative post.

Leave a Reply

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

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