I've developed a Magento website and i want to we select a customer each period of time within order than $1000 and give him a prize from the admin.
Any suggestion about that ?
I've developed a Magento website and i want to we select a customer each period of time within order than $1000 and give him a prize from the admin.
Any suggestion about that ?
Magento uses a mysql DB.
I don't know the DB schema really. Find a query that gives you all orders > $1000 for the given time interval. Then just pick a random row from the result. See answer Mysql 1 Random Row
Something like
SELECT DISTINCT customer_id from sales_order
WHERE created_at between ? and ?
AND grand_total > 1000
ORDER BY RAND() LIMIT 1
could actually work.
It will have a customer_id that you can then lookup in the customer_entity table.
Because I use DISTINCT in my query, even if a customer placed more than 1 $1000 order he only gets one chance at winning just like the other customers that placed only 1 $1000 order in the given time interval.