Forums / General Questions / how to know the customers who has ordered more than X times

how to know the customers who has ordered more than X times

Locked

Started by doubletiger on 14 Sep 2007, 3:41 PM · Views: 1,806

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
14 Sep 2007, 3:41 PM
#1
doubletiger avatar

doubletiger

Zen Follower

Join Date:
Apr 2005
Posts:
199
Plugin Contributions:
0

how to know the customers who has ordered more than X times

Hi,

I am planning to give some of regular customers a group discount, but do not know the quick way to find out who have ordered more than X times on my site and then apply the group discount to this group of customers.

can anyone help please?

thank you in advance!

Doubletiger

14 Sep 2007, 5:17 PM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,755
Plugin Contributions:
56

Re: how to know the customers who has ordered more than X times

I would suggest something more like total order volume:

SELECT customers_id, sum(order_total) FROM zen_orders group by customers_id order by order_total desc;

You wouldn't want to not give a discount to a customer who made one huge order, after all.

Good luck,
That Software Guy

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

14 Sep 2007, 5:17 PM
#3
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: how to know the customers who has ordered more than X times

You have to write code for that, not too difficult though.
Edit: oops, swguy posted first.

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

14 Sep 2007, 11:24 PM
#4
doubletiger avatar

doubletiger

Zen Follower

Join Date:
Apr 2005
Posts:
199
Plugin Contributions:
0

Re: how to know the customers who has ordered more than X times

Hi, Swguy

I tested it, it does work! thank you very much for your code!

Doubletiger

14 Sep 2007, 11:42 PM
#5
doubletiger avatar

doubletiger

Zen Follower

Join Date:
Apr 2005
Posts:
199
Plugin Contributions:
0

Re: how to know the customers who has ordered more than X times

Hi,

the code is working, but it only give total amount.

does anyone know where can I pull out "Number of Orders" from? I would like to know who has order more than X times.

thanks!

Doubletiger

15 Sep 2007, 12:06 AM
#6
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,755
Plugin Contributions:
56

Re: how to know the customers who has ordered more than X times

SELECT count(*) as count, customers_id from zen_orders group by customers_id order by count desc;

Good luck,
Scott

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

15 Sep 2007, 12:23 AM
#7
doubletiger avatar

doubletiger

Zen Follower

Join Date:
Apr 2005
Posts:
199
Plugin Contributions:
0

Re: how to know the customers who has ordered more than X times

swguy:

SELECT count(*) as count, customers_id from zen_orders group by customers_id order by count desc;

Good luck,
Scott

Hi, Swguy

this is the code I need! thank you very much!

Doubletiger