WooCommerce: Custom Order Number – Customer Billing Initials And Random Numbers

Replace the default WooCommerce Order ID format with a custom one of your own. This one used the customer’s billing initials and random numbers between 10,000 and 99,999.

woocommerce custom order number
Example of WooCommerce Custom Order ID – Generated from customers billing initials and a random number

Modify The Code

You can of course modify the code to generate a WooCommerce order number of your own format.

Have a look at the WC_Order object code reference to see what data is available to you.

Where To Put The Code Snippet?

This code snippet should go in your active theme’s functions.php file.

Add it to the bottom of the file, before any closing ?> characters.

It’s always a good idea to take a backup of your functions.php file in case anything goes wrong – you can just copy the old code back in again.

Are You New To WooCommerce?

If you haven’t yet started to build an email list of your WooCommerce shop customers, now is the best time to get started.

Was this article helpful?

Keep In Touch


Wil is a dad, WordPress consultant, WordPress developer, business coach and mentor. He co-organizes the WordPress Sydney meetup group and has been on the organising committee for WordCamp Sydney since 2014. He speaks at many special events and contributes to the WordPress open source project. His likes are chillies, craft beer and electrogravitics.