Coupon based on spending in the shop

Perhaps someone is able to help me wrap my head around the following:

I would like to send customers a coupon when their total spendings in the shop reach certain amounts, EG. you have spend $100.00 you get an email with a coupon code which gives you 5% discount on your purchases one time only. For $200.00 you get a coupon for 10% or something along those lines.

Of course I would need to check that someone who has already received a coupon for > $100.00 doesn't get another one, but I think I can get that in rules by checking the number of results of a view.

I added the commerce_coupon module and was thinking about how I could get the users with their total spendings but I have not yet found a way to do this. Views in my opinion would be the best way to go using aggregation to get the amounts, however it seems that the aggregation on the amounts is not working as expected, number of purchases seems okay but the sum is not being calculated.

Has anybody been working on views in combination with orders and aggregation? If so which versions have you used to successfully get totals from views.

As always I'd love to hear input from anybody with good ideas on how I can get the idea to work.

Posted: Nov 2, 2011


Qubical on January 7, 2012

I probably found the solution, aggregartion settings in views was set-up with the default order by date, this caused my aggregation to return unexpected values.