Forums / General Questions / How to Reset the Order ID back to 1 ?

How to Reset the Order ID back to 1 ?

Views: 865

Results 1 to 5 of 5
4 Sep 2011, 4:53 PM
#1
heyits007 avatar

heyits007

Zen Follower

Join Date:
Sep 2010
Posts:
270
Plugin Contributions:
0

How to Reset the Order ID back to 1 ?

How to Reset the Order ID back to 1 ?

I have duplicated my web site and database, so on the new site I'm starting orders from scratch and ideally would like to reset the ID to 1. I have deleted all the old order data on the duplicated site, so there are no orders on the new site that are using order no 1, so far as I'm aware.

I've been reading many comments about not being able to set the order ID back to 1 and the reasons why, however in this situation I'm starting from scratch for this new duplicated then modified site, so on the surface at least, it makes sense to reset the order ID back to 1, as I have not had any orders on this new site yet.

When I did a first test order on this new duplicated then modified site, the order number was no 35, which was the last order number of my original site when I backed it up and copied it to the new duplicated then modified site. It just seems to make more sense to restart at order no 1 for this new site, which as mentioned, does not yet have any real orders to its name.

Thus if it is technically possible, whilst maintaining the integrity of the remaining data on this new site, I would like to reset the order number back to 1. Thus then the question becomes, how ? Can I simply edit the order table via PhPMyAdmin or something ? or other method ?

Otherwise if there's another reason why the order number can't be set back to no 1 on what effectively is a new site, I would be interested to know why.

Thanks,
007

4 Sep 2011, 5:02 PM
#2
heyits007 avatar

heyits007

Zen Follower

Join Date:
Sep 2010
Posts:
270
Plugin Contributions:
0

Re: How to Reset the Order ID back to 1 ?

i.e. Order ID: 35 was the last new order number available from the old site, with the last completed order no being no 34, I presume, at the time the original site was backed up.

Thanks,
007

4 Sep 2011, 10:40 PM
#3
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: How to Reset the Order ID back to 1 ?

It is possible to do this via phpMyAdmin, where you drop or truncate the relevant tables/fields and then re-insert them and/or reset the auto-increment value.

But care is needed... The order ID is used in various places in the database, and what you don't want to happen is a data conflict where (for example) Mr Jones suddenly sees in his shopping history a whole bunch of orders he didn't make.

I can't recall what tables and fields are affected (perhaps others can advise), but I do know that "tinkering" in phpMyAdmin can produce some "interesting" results - including the possibility of breaking the entire store.

Proceed with caution.

20 years a Zencart User

5 Sep 2011, 3:59 PM
#4
heyits007 avatar

heyits007

Zen Follower

Join Date:
Sep 2010
Posts:
270
Plugin Contributions:
0

Re: How to Reset the Order ID back to 1 ?

Ok thanks. I will proceed with caution. I've backed up the database, so I can restore it if required. Not being a live site makes it a bit less risky, if things do go wrong in testing.

Thanks,
007

5 Sep 2011, 5:17 PM
#5
heyits007 avatar

heyits007

Zen Follower

Join Date:
Sep 2010
Posts:
270
Plugin Contributions:
0

Re: How to Reset the Order ID back to 1 ?

I successfully reset the order ID back to 1. I simply deleted the orders from within ZenCart Admin and then ran that SQL alter table command to reset the orders_id auto-increment value back to 0. I looked at the database orders structures and could see the data effected. Tested new orders and it worked ok starting from no 1 again.

However, I've noticed other table data still exists like PayPal transaction data and who knows what else. Thus without explicit instructions, it is a bit of a gamble in terms of retaining the integrity of the database, so I've decided to restore the database to its prior state.

I'm going to try go with the different approach of starting at a much higher number, set via the Admin option as per suggested at this stage. It may work out better that way anyway as both shopping sites feed into the one Paypal account and having a separate order numbering range makes it easier to distinguish the orders at first glance.

Thanks,
007