Zen Cart Logo
Forums / General Questions / How to remove all customers who have never ordered before?

How to remove all customers who have never ordered before?

Views: 6,006

Results 1 to 20 of 22
5 Sep 2011, 12:31 AM
#1
ebookba avatar

ebookba

New Zenner

Join Date:
Oct 2007
Posts:
31
Plugin Contributions:
0

How to remove all customers who have never ordered before?

My site is hit by registration spam, and removing each customer manually from the admin is not feasible.

I am now thinking about using phpmyadmin to do the job. What should be the mysql line to remove these spam from database?

Thanks in advanced.

5 Sep 2011, 2:25 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How to remove all customers who have never ordered before?

There are a number of tables that need to be addressed:
address_book
customers
customers_info
customers_basket
customers_basket_attributes
products_notifications

You would need to verify the customers_id against the table:
orders

If nothing is found, then clean up the customer tables ...

It would be a good idea to also check against the table:
customers_info

for when the customer's account was created so that you do not delete customers that are new, without orders, but may have not had time to complete or make an order yet ...

6 Sep 2011, 2:46 PM
#3
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Re: How to remove all customers who have never ordered before?

I tell you what ive found with the spammers, is they always select the first country on your country list. So I have made my first country option 'Please Select' so then I know which ones are spam.

11 Sep 2011, 12:15 AM
#4
ebookba avatar

ebookba

New Zenner

Join Date:
Oct 2007
Posts:
31
Plugin Contributions:
0

Re: How to remove all customers who have never ordered before?

Thanks for replies.
Actually the spammers on my site come from the same source and use the exact same address when registration. But because I'm not very familiar with server programming, I still cannot figure out a way to mass delete them from database.

12 Sep 2011, 9:01 AM
#5
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Re: How to remove all customers who have never ordered before?

ebookba:

Thanks for replies.
Actually the spammers on my site come from the same source and use the exact same address when registration. But because I'm not very familiar with server programming, I still cannot figure out a way to mass delete them from database.

Well thats easy then. If they all use the same address just search for that address in the customers table, and it will bring up all the customer with that address in a big list. Then you can mass delete.

13 Sep 2011, 4:24 PM
#6
magicman avatar

magicman

Zen Follower

Join Date:
Oct 2007
Location:
MA, USA
Posts:
385
Plugin Contributions:
0

Re: How to remove all customers who have never ordered before?

Sounds like there are quite a few of us having the same bogus customer issues. Mine are all coming from China. I have recorded the ip addresses and have blocked them on my hosting server. This has taken care of it for me. I blocked out the entire range of them. I know, this stinks.

16 Sep 2011, 6:32 PM
#7
toujours avatar

toujours

New Zenner

Join Date:
Feb 2010
Posts:
7
Plugin Contributions:
0

Re: How to remove all customers who have never ordered before?

Hiya,

I seem to have the same problem on one of my sites, starting about the 10th of the month. I've successfully deleted all of the offending "customers," but from what I can tell, they've set up a proxy in Sweden. I don't want to block potential customers coming from Sweden, so I'm loath to set up an .htaccess deny. Does anyone have others ideas how to prevent more of this from trickling in?

Thanks in advance...

27 Sep 2011, 4:28 PM
#8
freya avatar

freya

Zen Follower

Join Date:
Mar 2006
Posts:
122
Plugin Contributions:
0

Re: How to remove all customers who have never ordered before?

I am having the same problem. How do I do the search in myPHPadmin? They use one of two addresses with bogus names. And they are all from China.

27 Sep 2011, 5:12 PM
#9
freya avatar

freya

Zen Follower

Join Date:
Mar 2006
Posts:
122
Plugin Contributions:
0

Re: How to remove all customers who have never ordered before?

I couldn't do the search as it didn't turn up anything, but I did manage to do bulk deletes by going into the address book in phpMyAdmin and deleting entire pages of spam customers. 30 at a time is much quicker than one. I am going to try the suggestion that makes them pick a country. Maybe that will slow them down. (Thanks for that suggestions, BTW.) :)

28 Sep 2011, 8:44 AM
#10
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Re: How to remove all customers who have never ordered before?

freya:

I couldn't do the search as it didn't turn up anything, but I did manage to do bulk deletes by going into the address book in phpMyAdmin and deleting entire pages of spam customers. 30 at a time is much quicker than one. I am going to try the suggestion that makes them pick a country. Maybe that will slow them down. (Thanks for that suggestions, BTW.) :)

It works, I confirmed it last night, with no sign ups. Go into phpadmin and change the '-Please Select' country ID to 0. Thats all you have to do. You don't need to chanege the code in create_account.php.

28 Sep 2011, 6:10 PM
#11
jgold723 avatar

jgold723

Zen Follower

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

Re: How to remove all customers who have never ordered before?

It was easy to scan the customers table and find the fakes -- so I simply deleted them and figured I was done.

But as others have noted, there are other tables in the database that refer to the (now deleted) customer ids.

My question is -- will this cause any problems down the road? I did this several weeks ago and we haven't experienced any issues, so I'm guessing we're OK. But if there's some kind of cleanup or database realignment that needs doing, I've love to know.

29 Sep 2011, 4:13 AM
#12
drbyte avatar

drbyte

Sensei

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

Re: How to remove all customers who have never ordered before?

YES, you should clean up the rest of the data. NEVER BLINDLY HACK OUT RECORDS IN THE DATABASE WITHOUT BEING SURE YOU KNOW WHAT YOU'RE DOING!!!!!

29 Sep 2011, 11:37 AM
#13
jgold723 avatar

jgold723

Zen Follower

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

Re: How to remove all customers who have never ordered before?

Message heard and lesson learned (the way I learn most of my lessons, the hard way).

But, this raises two questions:

  1. I'm assuming I'd need to:
    -- Find the IDs of all the records I deleted;
    -- Find the tables where those IDs are still in existence;
    -- Delete the records with those IDs from the tables

This would be incredibly time consuming, not to mention I increase the possibility of deleting records that shouldn't be. Is there a utility that can do these comparisons and clean up the database?

  1. Is there (and if there isn't, why?) a ZC extension that will facilitate the deletion of customers? Right now the only options seem to be to ban the customer or limit their shopping options. A utility that would allow customer records to be easily deleted enmasse would be incredibly useful.
18 Dec 2016, 9:40 PM
#14
fakedecoy avatar

fakedecoy

Zen Follower

Join Date:
Jul 2006
Posts:
309
Plugin Contributions:
0

Re: How to remove all customers who have never ordered before?

I'm having this issue too with lots of spam customers I need to delete. Basically ones using the company name of AT&T, microsoft, and apple.

It looks like it would just take a good SQL DELETE query with the right JOIN keywords to clean up these tables. Has anyone come up with one?

address_book
customers
customers_info
customers_basket
customers_basket_attributes
products_notifications

20 Dec 2016, 5:49 PM
#15
drbyte avatar

drbyte

Sensei

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

Re: How to remove all customers who have never ordered before?

fakeDecoy:

I'm having this issue too with lots of spam customers I need to delete. Basically ones using the company name of AT&T, microsoft, and apple.

It looks like it would just take a good SQL DELETE query with the right JOIN keywords to clean up these tables. Has anyone come up with one?

address_book
customers
customers_info
customers_basket
customers_basket_attributes
products_notifications

I find that usually when people are asking something this specific they've already started deleting customer records from the customers table using some tool like phpMyAdmin (or even better something like Navicat or SqlYog or SequelPro). In such cases, running the following will very quickly (in a few seconds) clean up (delete) the associated records from the other related tables:```
update reviews set customers_id = null where customers_id not in (select customers_id from customers);delete from address_book where customers_id not in (select customers_id from customers);
delete from customers_info where customers_info_id not in (select customers_id from customers);
delete from customers_basket where customers_id not in (select customers_id from customers);
delete from customers_basket_attributes where customers_id not in (select customers_id from customers);
delete from whos_online where customer_id not in (select customers_id from customers);
delete from products_notifications where customers_id not in (select customers_id from customers);

20 Dec 2016, 10:16 PM
#16
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,963
Plugin Contributions:
8

Re: How to remove all customers who have never ordered before?

DrByte:

I find that usually when people are asking something this specific they've already started deleting customer records from the customers table using some tool like phpMyAdmin (or even better something like Navicat or SqlYog or SequelPro). In such cases, running the following will very quickly (in a few seconds) clean up (delete) the associated records from the other related tables:```
update reviews set customers_id = null where customers_id not in (select customers_id from customers);delete from address_book where customers_id not in (select customers_id from customers);
delete from customers_info where customers_info_id not in (select customers_id from customers);
delete from customers_basket where customers_id not in (select customers_id from customers);
delete from customers_basket_attributes where customers_id not in (select customers_id from customers);
delete from whos_online where customer_id not in (select customers_id from customers);
delete from products_notifications where customers_id not in (select customers_id from customers);


i think what is missing from here is the initial delete....  if you wanted to delete all customers who have not ordered, you could use something like:

delete from customers where customers_id not in (select customers_id from orders);


and then follow with all of the remaining sql statements.

if you wanted to delete ones with the company name, it gets a little trickier as the company name is stored in the address_book table and we would have to incorporate that into the initial delete.

as with all SQL statements, i encourage you to remember an old Shakespearean saying:

"to err is human... to screw things up, you need a computer....  and to screw things up royally, you need sql...."

good luck!
20 Dec 2016, 11:56 PM
#17
drbyte avatar

drbyte

Sensei

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

Re: How to remove all customers who have never ordered before?

carlwhat:

i think what is missing from here is the initial delete
Yes. That was quite intentional, as giving an initial delete is destructive without any constraints, and could be terribly harmful if someone "just does it" without understanding the bigger picture.

As you said, doing specific deletions based on specific criteria, is a separate exercise.

21 Dec 2016, 1:31 AM
#18
fakedecoy avatar

fakedecoy

Zen Follower

Join Date:
Jul 2006
Posts:
309
Plugin Contributions:
0

Re: How to remove all customers who have never ordered before?

Cool, thanks! I think that will do the trick in helping me to clean spam out of my customer db.

21 Dec 2016, 10:32 PM
#19
fakedecoy avatar

fakedecoy

Zen Follower

Join Date:
Jul 2006
Posts:
309
Plugin Contributions:
0

Re: How to remove all customers who have never ordered before?

FYI, my queries to delete customers with zero lifetime orders and with no activity for 6 months:

DELETE from zen_customers
WHERE customers_id IN
	(SELECT customers_info_id from zen_customers_info where TIMESTAMPDIFF(MONTH,customers_info_date_account_created, NOW()) > 6
AND TIMESTAMPDIFF(MONTH,customers_info_date_of_last_logon, NOW()) > 6)	
AND customers_id NOT IN
	(SELECT customers_id FROM zen_orders);


update zen_reviews set customers_id = null where customers_id not in (select customers_id from zen_customers);
delete from zen_address_book where customers_id not in (select customers_id from zen_customers);
delete from zen_customers_info where customers_info_id not in (select customers_id from zen_customers);
delete from zen_customers_basket where customers_id not in (select customers_id from zen_customers);
delete from zen_customers_basket_attributes where customers_id not in (select customers_id from zen_customers);
delete from zen_whos_online where customer_id not in (select customers_id from zen_customers);
delete from zen_products_notifications where customers_id not in (select customers_id from zen_customers);
12 Jan 2018, 12:57 PM
#20
jakelawless avatar

jakelawless

Zen Follower

Join Date:
Jan 2018
Posts:
146
Plugin Contributions:
0

Re: How to remove all customers who have never ordered before?

Which php file on the ftp does this code go in to?