Is there a easy way to start Craft Commerce order ids form a higher number? So the can follow on from an old system and not overlap?

autoincrement in the DB table maybe?


You can write a Craft plugin that listens to the onBeforeOrderComplete event and implement whatever sort of order number format your business requirements require.

Alternatively here's an existing plugin that uses that method that might already cover your needs: https://github.com/bossanova808/CommerceFriendlyOrderNumbers

| improve this answer | |
  • Sorry Brad just to check is there no way to just skip the the ID of craft_commerce_orders DB table on to for example 2000 as a starting point? – Green17 Nov 10 '16 at 21:42
  • @Green17 the order ID is not incremental. It is the next Craft element ID. Elements in Craft are entries, categories, products, orders etc. So there is no way to make order.id incremental. Best using a custom field with the plugin brad mentioned. – Luke Holder Nov 10 '16 at 22:10
  • @Green17 my plugin (above) will do exactly what you want - you can start at 2000 (or any number) and you'll get consecutive numbers from them on. We're about to clear the first 1000 orders with it (starting at ~25000 from our old cart) - so pretty confident it works well at this point. It's pretty easy to implement but if you get stuck find me on slack and I'll help you out. – Jeremy Daalder Nov 10 '16 at 22:41
  • Thanks so much for all you help, I will use you plugin Jeremy. – Green17 Nov 10 '16 at 22:51
  • @JeremyDaalder your plugin worked great thanks so much for your and Brads help. – Green17 Nov 14 '16 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.