WooCommerce is engineered with a simple but effective philosophy: include all the functionality required to create a basic eCommerce shop in a free and extendable plugin, and delegate all other features to free and premium extensions. The full implications and benefits of such a strategy will be discussed in a future article; while the remainder of this one will delve into its consequences for order numbers and how to customize them to fit your needs with the help of two different plugins.

Non-sequential WooCommerce Order Numbers Explained

Some new WooCommerce shop administrators are surprised to find that their order numbers are non-sequential by default, for instance the first five orders placed in a new shop may be assigned numbers 5, 6, 13, 14, 27. Depending on your particular wants or business/regulatory/accounting requirements this behavior could range from being a non-issue, to desirable (competitors/customers less insight into what your shop order volume is like), to mildly inconvenient, to outright unacceptable. The technical reason WooCommerce order numbers appear in this seemingly random sequence is simply because a WooCommerce Order record is represented within the database by a WordPress Post and the post id is used as the order id. If you have an active site with new posts/pages being created, or other plugins also creating post records for their own purposes, you’ll wind up with order numbers with these apparent gaps. Thankfully you have a few options, both free and paid, to deal with this.

Attaining (Free!) Sequential Order Numbers

If all you want or need is to have your order numbers without the aforementioned gaps you can achieve this by simply installing the free WooCommerce Sequential Order Numbers plugin released and maintained by SkyVerge (an sponsor of Sell with WP). This plugin will begin assigning sequential order numbers as soon as its installed and activated; existing order numbers, even if they contain gaps, will not be altered, both for your existing customers’ and your accountants’ sanity.

Taking Your Order Numbers to the Next Level

If you want complete control over your order numbers, combined with the peace of mind that an officially-supported premium WooCommerce plugin provides, the answer is Sequential Order Numbers Pro (also released by SkyVerge). This plugin is fully compatible with the free version and will upgrade existing order numbers when installed. As you might expect the premium version guarantees the same sequential order numbers offered by the free plugin but with a number of significant benefits which, at the time of writing, include:

Order numbers can be started from any number. By default in a shop with existing orders the sequential order numbers will pick up from the highest current order number. If desired, order numbers can be started from a number greater than the highest order number. For new shops with no existing orders, the first order number can be whatever you want, even zero.

Custom order number length. The premium plugin allows you to set an order number length, which causes zeroes to be added to the front of your custom order numbers to ensure they are a certain length. For instance, with a length of 5 configured, order number 241 will be presented as 00241.

Dynamic order number prefix and suffix. You can add a custom order number prefix or suffix to your order numbers, consisting of letters, numbers, dashes, etc, and even containing the current year, month, day, hour, second or minute when the order was placed. With this feature plus the previous two, order numbers such as SV-1001-20130731, SV-1002-20130731, SV-1003-20130801 are a breeze to set up.

Free orders can be excluded from the main sequence. Useful in jurisdictions or countries where order or invoice numbers must be sequential for accounting purposes, this option allows you to exclude free orders from the normal order number sequence. Additionally, a free order prefix can be configured, so that an “order” for a sample product that doesn’t represent a financial transaction could be something like FREE-10, leaving your paid order numbers perfectly sequential.

Many of the above features were added to the Sequential Order Numbers Pro plugin over time and as requested by customers with various order number requirements, and more features and options will doubtless be added in the future as the number of WooCommerce-powered shops expands and with it the need for more customized order numbers.

Read More

Disclosure: The author of this article is a co-founder of SkyVerge, Inc., who wrote the plugins discussed.

Note: Some of our posts contain affiliate links. Providing the most comprehensive and objective WordPress eCommerce resources is our mission regardless of whether the post contains affiliate links or not. Have more questions? See our affiliate policy. You can use the plain links below if you prefer that we not receive a referral commission:

Articles you may also like:

Posted by Justin Stern

Justin is a cofounder of SkyVerge and a frequent Sell with WP contributor. He loves writing technical reviews and how-to articles, but thinks writing code is far easier than writing words.

6 Comments

  1. I would never prefer a incremental and clean order sequence. The problem is that competitors can check how many orders you have i a given time, simply by cancelling the order in the payment process and atching the order_id parameter in the URL.

    1. Hi Bernardo, the order number used is actually separate from the order id, which is the post ID. Technically checking order ids will simply tell someone how many posts in total have been created in the meantime, not simply how many orders have been created. The order number is not accessible externally. Hopefully that clarifies how these plugins work!

  2. Add this code to your theme functions.php

    // PREFIX ORDERNUMMER
    add_filter( 'woocommerce_order_number', 'prefix_woocommerce_order_number', 1, 2 );
    
    function prefix_woocommerce_order_number( $oldnumber, $order ) {
    	return 'PREFIX_' . $order->id;
    }
    

    1. Hey Sjaak, thanks for sharing! For reference to any readers, this will add a prefix to your order numbers. However, note that this won’t be compatible with the free sequential order numbers plugin listed, as it uses it’s own order number counter rather than the order id (which is the same as the post_id here – the non-sequential number).

  3. Sjaak’s method works well. Simply change “PREFIX_” with what you want to be in front of your order numbers. Adding a single number here will add that number in front of your order numbers… Making it look as if you have had more orders or changing it to a letter to differentiate different web properties. Useful, for sure! Thank you for sharing, Beka and Sjaak!

It's been over 2 years since this post was published, so comments have been closed. Thanks for reading!