Edit or change order numbers in Woocommerce (without a plugin)

av tonny on 14/01/2015

Are you tired of all that plugins you need to edit or change anything in Woocommerce? Sure I am, anything costs too much.
The reason that I write this post is that I wanted my order numbers start in a new series. My order numbers was 1016, 1017 and so on. I needed the numbers to be in a series like 61016, 61017 and so on.

So I rearched and did only find the Woocommerce plugin “Sequential Order Numbers Pro” witch costs $49 for a single site. Not good for such a small edit. (You can also get that plugin form suspect sites like WooGang for $10 or $15, but you shouldnt buy there, they could be full of viruses and back doors to your WP admin.)

So I decided to dig into the database to make the changes. And it was easy. I followed these steps:

1. I made a new fake order in woocommerece, the order number became 1018
2. I logged into phpMyAdmin
3. I searched all tables for 1018
4. I edited this tables:

– dfE4_posts
– dfE4_woocommerce_order_itemmeta
– dfE4_woocommerce_order_items

How did I edit those tables?
I opened each table and just replaced the number 1018 with the number 61018 (witch is the number I needed my new series to start with).

5. Made a new fake order to check what the next order number would be.
6. Did not delete that fake orders so that when a real order was placed that order would have the order number 61019. Then I deleted my fake orders.

Please check Erryn Deane`s comment below before you start editing.

{ 4 kommentarer… les dem eller skriv en selv }

Dan Mackison 08.25.15 at 01:34

How did changing the number remove the way that Woocommerce randomizes order numbers? I feel like a step is missing here.

tonny 08.25.15 at 08:15

Does it matter why it works, it works 🙂

BTW, as far as I know, Woocommerce does not randomize order numbers once you get your first order.

Grace Alexander 07.28.17 at 03:08

THANK YOU. I really appreciate this post, I was able to edit like you said and change the order number -resolving a serious issue with duplication due to a cloned site. Saved my life. Best – Grace

Erryn Deane 09.27.17 at 11:09

A little update for peeps who need to change the order_id in the db (database). The original solution doesn’t quite work due to changes in woocommerce, so you need I needed to mod references to the order_id in the following areas:


Sometimes the id is preceded or followed by an additional number which also relates to the same order, so you need to be quite selective (I made about 30 changes in all). Then flush mysql cache, any other caching systems (redis etc.) then clear transients & sessions (woocommerce>status>tools) to be sure.

Honestly tried the original solution around 5 times until I decided to be totally thorough! Needed a fix for a review system (yotpo) after a website migration so the order_id’s where overlapping and no reviews where being sent out. No plugin does alters the order_id in the db, nothing can do it without the potential of messing things up I suppose, so this manual edit is the only solution.

Skriv en kommentar

Du kan bruke disse HTML taggene og attributtene: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Previous post:

Next post: