Zen Cart Logo
Forums / General Questions / Delete all orders

Delete all orders

Views: 1,646

Results 1 to 3 of 3
29 May 2013, 12:25 PM
#1
bonheddwr avatar

bonheddwr

Zen Follower

Join Date:
Jun 2007
Location:
Cymru
Posts:
124
Plugin Contributions:
0

Delete all orders

Hi,

Long story, but I'm splitting my Zen Cart store in two to go on 2 different domains. Some products will stay on the original Store, and others will be on the new store. There is a very good reason for this, but I will not bore you with that!

Anyway, I have cloned my entire store (files and DB) to the new domain, and I am in the process of deleting the unnecessary products/pages on the new store, and then I will do the same on the old store. There will be no duplication. Can anyone suggest a SQL Patch that will delete ALL orders/order history from my new store? I want to keep the order history on my old domain only, as that is where the order was placed. I have found the following link, and a helpful SQL Patch by DrByte, but this will delete all customer data as well.

http://www.zen-cart.com/showthread.php?140440-Can-i-delete-all-my-customers

I want to allow customers to login at the old & new store, but want to delete the orders they placed only at the new store. I will email all customers who have signed up to the newsletter to let them know that some of the products are now only available on the old store, and others on the new store, and to let them know that they can login to the old or new store using their current login details, but that their order history is only available at the old store.

Thank you for any help. Here is DrBytes SQL code:

truncate table customers;
truncate table address_book;
truncate table customers_info;
truncate table group_pricing;
truncate table orders;
truncate table orders_products;
truncate table orders_status_history;
truncate table orders_products_attributes;
truncate table orders_products_download;
truncate table orders_total;
truncate table admin_activity_log;
truncate table authorizenet;
truncate table banners_history;
truncate table counter;
truncate table counter_history;
truncate table coupon_email_track;
truncate table coupon_gv_customer;
truncate table coupon_gv_queue;
truncate table coupon_redeem_track;
truncate table coupon_restrict;
truncate table customers_basket;
truncate table customers_basket_attributes;
truncate table db_cache;
truncate table email_archive;
truncate table files_uploaded;
truncate table paypal;
truncate table paypal_payment_status_history;
truncate table paypal_session;
truncate table sessions;
truncate table upgrade_exceptions;
truncate table whos_online;

PS. Both stores are v1.3.9h. I will update to thew newest version, after doing the work on both stores.

29 May 2013, 5:27 PM
#2
drbyte avatar

drbyte

Sensei

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

Re: Delete all orders

Try the following, based solely on your quote above, not on any thorough inspection of the database. I have not tested this. Use at your own risk.
CAVEAT: USE AT YOUR OWN RISK! MAKE DATABASE BACKUPS BEFORE DOING ANY OF THIS SORT OF THING!
ONE SHOULD RARELY EVER USE "truncate" STATEMENTS ON THE DATABASE! THIS IS A DESTRUCTIVE ACTION AND WILL RESULT IN LOSS OF DATA!

truncate table orders;
truncate table orders_products;
truncate table orders_status_history;
truncate table orders_products_attributes;
truncate table orders_products_download;
truncate table orders_total;
truncate table admin_activity_log;
truncate table authorizenet;
truncate table banners_history;
truncate table counter;
truncate table counter_history;
truncate table coupon_email_track;
truncate table coupon_gv_customer;
truncate table coupon_gv_queue;
truncate table coupon_redeem_track;
truncate table coupon_restrict;
truncate table customers_basket;
truncate table customers_basket_attributes;
truncate table db_cache;
truncate table email_archive;
truncate table files_uploaded;
truncate table paypal;
truncate table paypal_payment_status_history;
truncate table paypal_session;
truncate table sessions;
truncate table upgrade_exceptions;
truncate table whos_online;
30 May 2013, 9:15 AM
#3
bonheddwr avatar

bonheddwr

Zen Follower

Join Date:
Jun 2007
Location:
Cymru
Posts:
124
Plugin Contributions:
0

Re: Delete all orders

Many thanks. :-) Seems to have worked perfectly. All orders deleted, but all customer accounts still there. I will do more tests, and post if there are any issues, incase someone else wants to do something similar. I also have, of course, the full back of the database before running the script.