I want to create a rule based on the number of sales per product. Is there a data selector to get the number of sales per product? If anyone can point me in the right direction, I will be very grateful!
3 Answers
I don't think you'll find that particular condition out of the box. Conditions for rules are pretty easy to write though, check Commerce Conditions for some easy to follow examples.
Exactly what kind of rule you want to create? What do you want to accomplish with it? You could do a database query that returns you "the number of sales per product" and then perform an action based on that number, and run this on a cron job. But since we don't know how sales or products are represented in your site, not what exactly your rule will try to accomplish, we cannot point you in the right direction.
You could use Commerce Product Popularity, which uses a Radioactivity field that increases with each purchase. If you switch off decay and configure the rule with an energy of 1, then the field will contain the total units sold for that product since the field was last cleared.