Jump to content

How to change order ID?


Recommended Posts

So you've got existing orders 6, 7, 8, etc that you want to change to 1, 2, 3, etc? You'll need to use an SQL query like the following to fix that:

UPDATE `ps_orders` SET `id_order` = `id_order` - 5;
UPDATE `ps_order_detail` SET `id_order` = `id_order` - 5;
UPDATE `ps_order_discount` SET `id_order` = `id_order` - 5;
UPDATE `ps_order_return` SET `id_order` = `id_order` - 5;
UPDATE `ps_order_slip` SET `id_order` = `id_order` - 5;



This will subtract 5 from all the order IDs. You can then use an autoincrement query like my one above to set the next order ID.

Link to comment
Share on other sites

They shouldn't be. That query doesn't delete any orders. It only subtracts 5 from the order ID. You can use the following query to add 5 to undo the change:

UPDATE `ps_orders` SET `id_order` = `id_order` + 5;
UPDATE `ps_order_detail` SET `id_order` = `id_order` + 5;
UPDATE `ps_order_discount` SET `id_order` = `id_order` + 5;
UPDATE `ps_order_return` SET `id_order` = `id_order` + 5;
UPDATE `ps_order_slip` SET `id_order` = `id_order` + 5;

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...