Zen Cart Logo
Forums / Managing Customers and Orders / Reset store: Delete all orders, customers, etc.

Reset store: Delete all orders, customers, etc.

Views: 8,581

Results 1 to 17 of 17
8 Aug 2010, 6:09 PM
#1
flix avatar

flix

New Zenner

Join Date:
Mar 2010
Posts:
33
Plugin Contributions:
0

Reset store: Delete all orders, customers, etc.

Hello

I want to setup a new ZC store by copy-pasting the files and database of my other running ZC store.

Of course, copy-pasting not only sets up an identical second store but also includes old orders, old customers, ect. of the old store into the new store.

Does anyone have an idea how I would be able to set my new copied store "to zero", i.e. to delete all old orders, customers, etc. from it?

I suppose you would be able to do that via deleting tables in the database, but I am not sure this would be a wise thing to do since this may break referencial integrity of the database ...

And deleting every order etc. by hand is just too exhaustive.

Any advice would be greatly appreciated!!!
Thanks!

8 Aug 2010, 6:43 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Reset store: Delete all orders, customers, etc.

you would be able to do that via deleting tables in the database, but I am not sure this would be a wise thing to do since this may break referencial integrity of the database
You do not delete them
You can empty them and this retains the table & structure
There are many that will require being emptied as orders are indexed to customer, products purchased, etc....

9 Aug 2010, 7:31 PM
#3
flix avatar

flix

New Zenner

Join Date:
Mar 2010
Posts:
33
Plugin Contributions:
0

Re: Reset store: Delete all orders, customers, etc.

kobra:

There are many that will require being emptied as orders are indexed to customer, products purchased, etc....

Hi Kobra

In my view, this is exactly the issue. If I delete the content of some tables like orders and customers, I expect that many other tables having references to these emptied tables would need to be adapted/emptied as well. If I don't find all of these references, I would expect that this could damage my database in a pretty unpredictable way.

And I have actually neither a clue which tables I would have to empty/adapt nor have I found a list of such tables anywhere on the web.

But on the other hand, I can not believe that there is no elegant solution to this issue (e.g. a cute sql script setting back the database would be nice...).

Has anyone solved this issue in an elegant manner???

9 Aug 2010, 8:37 PM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Reset store: Delete all orders, customers, etc.

I would expect that this could damage my database in a pretty unpredictable way.
This is why one should always BACKUP BACKUP BACKUP

21 Mar 2011, 2:56 PM
#5
dysfunctional avatar

dysfunctional

Zen Follower

Join Date:
Apr 2008
Posts:
159
Plugin Contributions:
0

Re: Reset store: Delete all orders, customers, etc.

flix:

But on the other hand, I can not believe that there is no elegant solution to this issue (e.g. a cute sql script setting back the database would be nice...).

Has anyone solved this issue in an elegant manner???

Sorry for bumping this old thread but I have the same issue.

I need to setup a new identical store. I've worked hard installing all modules and modifications and do not wish to start from scratch again :).

Is my only option here to manually empty the required database fields?

If so, maybe it's easier to setup a new store from scratch anyways.

Hmmm...

13 Sep 2011, 7:49 PM
#6
eastsideangus avatar

eastsideangus

New Zenner

Join Date:
Feb 2011
Posts:
2
Plugin Contributions:
0

Re: Reset store: Delete all orders, customers, etc.

Hey, I was looking for some time on how to delete all the orders and customers from my installation of zencart, after no luck in finding it online, I just created an sql script to do this.

This is pretty much it here, it's helped me. Hopefully it will help you.
NOTE: this won't touch any of the products or artists, or admin accounts, etc...

Just the Orders and Customers. And any session entries related to them.

Use at your own risk, of course:

DELETE FROM zc_address_book;
DELETE FROM zc_coupon_email_track;
DELETE FROM zc_coupon_gv_customer;
DELETE FROM zc_coupon_gv_queue;
DELETE FROM zc_coupon_redeem_track;
DELETE FROM zc_customers;
DELETE FROM zc_customers_basket;
DELETE FROM zc_customers_basket_attributes;
DELETE FROM zc_customers_info;
DELETE FROM zc_customers_wishlist;
DELETE FROM zc_email_archive;
DELETE FROM zc_files_uploaded;
DELETE FROM zc_orders;
DELETE FROM zc_orders_products;
DELETE FROM zc_orders_products_attributes;
DELETE FROM zc_orders_products_download;
DELETE FROM zc_orders_status_history;
DELETE FROM zc_orders_total;
DELETE FROM zc_paypal;
DELETE FROM zc_paypal_session;
DELETE FROM zc_paypal_testing;
DELETE FROM zc_reviews;
DELETE FROM zc_reviews_description;
DELETE FROM zc_sessions;
DELETE FROM zc_whos_online;
21 Mar 2012, 1:26 PM
#7
jgold723 avatar

jgold723

Zen Follower

Join Date:
Dec 2010
Posts:
362
Plugin Contributions:
0

Re: Reset store: Delete all orders, customers, etc.

Has anyone else tried this? I'd in the same situation, but I really would hate to cause a massive problem if there's a flaw in this.

BTW - I'm amazed that someone hasn't come up with a more elegant solution to this problem -- I would think that the ability to clear out customer and order data in an efficient manner would be key to an ecommerce system.

(I know that sounds snarky, but I don't mean it to -- I'm just surprised that ZC doesn't have this function).

19 Apr 2012, 10:38 AM
#8
daisy606 avatar

daisy606

New Zenner

Join Date:
Apr 2011
Posts:
10
Plugin Contributions:
0

Re: Reset store: Delete all orders, customers, etc.

I had copied my files over to create another store so that I wouldn't have to add all my stock again.

I took a chance, tried this and it worked! I just need to reset the hit counter.

Thank you!

22 Apr 2012, 8:22 PM
#9
bn17311 avatar

bn17311

Zen Follower

Join Date:
Apr 2010
Posts:
319
Plugin Contributions:
0

Re: Reset store: Delete all orders, customers, etc.

same here 6000 orders and 1000s of customers deleted and new orders now taken and everything great

thanks eastsideangus great quick delete

bn

27 Apr 2012, 1:36 AM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Reset store: Delete all orders, customers, etc.

There is AT LEAST one glaring flaw with eastsideangus' method: all your product and customer and order numbers in the new store will start at the number where the old store left off, and NOT at 1.

REMEMBER: USE AT OWN RISK

13 Jun 2012, 1:30 PM
#11
kinembe avatar

kinembe

New Zenner

Join Date:
Aug 2008
Posts:
62
Plugin Contributions:
0

Re: Reset store: Delete all orders, customers, etc.

ok, but what exactly would i need to do with this code?

13 Jun 2012, 3:24 PM
#12
balihr avatar

balihr

Totally Zenned

Join Date:
Oct 2008
Location:
Croatia
Posts:
1,782
Plugin Contributions:
21

Re: Reset store: Delete all orders, customers, etc.

Make sure you backup your database first.

After the backup, you can run this from admin->Tools->Install SQL Patches.

Use at your own risk!!!

13 Jun 2012, 4:54 PM
#13
kinembe avatar

kinembe

New Zenner

Join Date:
Aug 2008
Posts:
62
Plugin Contributions:
0

Re: Reset store: Delete all orders, customers, etc.

i tried running the script but i get this error:

1146 Table 'tax1111403152225.zen_zc_address_book' doesn't exist
in:
[DELETE FROM zen_zc_address_book;]
If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.

13 Jun 2012, 5:48 PM
#14
balihr avatar

balihr

Totally Zenned

Join Date:
Oct 2008
Location:
Croatia
Posts:
1,782
Plugin Contributions:
21

Re: Reset store: Delete all orders, customers, etc.

oh, sorry, wasn't looking at the statement...

remove ALL zc_ from it so it goes like
DELETE FROM address_book;
etc

13 Jun 2012, 6:40 PM
#15
kinembe avatar

kinembe

New Zenner

Join Date:
Aug 2008
Posts:
62
Plugin Contributions:
0

Re: Reset store: Delete all orders, customers, etc.

it seems to have worked for me, thanks for the help!!

31 Oct 2012, 6:57 PM
#16
hawkwynd avatar

hawkwynd

New Zenner

Join Date:
Jun 2007
Location:
Nashville, TN
Posts:
32
Plugin Contributions:
1

Re: Reset store: Delete all orders, customers, etc.

EastSideAngus:

Hey, I was looking for some time on how to delete all the orders and customers from my installation of zencart, after no luck in finding it online, I just created an sql script to do this.

This is pretty much it here, it's helped me. Hopefully it will help you.
NOTE: this won't touch any of the products or artists, or admin accounts, etc...

Just the Orders and Customers. And any session entries related to them.

Use at your own risk, of course:

DELETE FROM zc_address_book;
DELETE FROM zc_coupon_email_track;
DELETE FROM zc_coupon_gv_customer;
DELETE FROM zc_coupon_gv_queue;
DELETE FROM zc_coupon_redeem_track;
DELETE FROM zc_customers;
DELETE FROM zc_customers_basket;
DELETE FROM zc_customers_basket_attributes;
DELETE FROM zc_customers_info;
DELETE FROM zc_customers_wishlist;
DELETE FROM zc_email_archive;
DELETE FROM zc_files_uploaded;
DELETE FROM zc_orders;
DELETE FROM zc_orders_products;
DELETE FROM zc_orders_products_attributes;
DELETE FROM zc_orders_products_download;
DELETE FROM zc_orders_status_history;
DELETE FROM zc_orders_total;
DELETE FROM zc_paypal;
DELETE FROM zc_paypal_session;
DELETE FROM zc_paypal_testing;
DELETE FROM zc_reviews;
DELETE FROM zc_reviews_description;
DELETE FROM zc_sessions;
DELETE FROM zc_whos_online;



Runing v1.5 - Glad I made a backup copy, because after running this script, new orders placed are not showing up in the admin Orders area, and the customer's order history. 

If someone has found a script to safely delete all orders without corrupting the database, then Please Post it here. 

Thank you!
31 Oct 2012, 7:04 PM
#17
hawkwynd avatar

hawkwynd

New Zenner

Join Date:
Jun 2007
Location:
Nashville, TN
Posts:
32
Plugin Contributions:
1

Re: Reset store: Delete all orders, customers, etc.

Here's what happened...

I had the orders_status table in the script... orders_status should NOT be deleted.

I removed that one, and the script worked perfectly.
See http://www.zen-cart.com/showthread.php?201895-Remove-ALL-customers-and-ALL-orders-before-a-certain-date-and-reset-counter-history