/
[in-commerce] Affiliate commission calculation issues [5.2.1]
[in-commerce] Affiliate commission calculation issues [5.2.1]
Resetting Affiliate Totals
There is affil:OnResetStatistics
event, that is executed on each page. The event checks for any affiliate records, where affiliate plan period is over and resets their totals:
- total items count, from orders associated with particular affiliate
- order total amounts, from orders associated with particular affiliate
Instead I recommend doing that in Scheduled Task once per day at 00:00.
Calculating Affiliate Commissions
Right now affiliate commission calculations happens real-time when order is approved.
This has 2 implications:
- ridiculously complex commission calculation code (we need to recalculate commissions for each past order in current affiliate plan period on every new approved order)
- affiliate gets commissions from orders, that were first approved, but then declined
Affiliate association
Right now if user is affiliate himself and he makes a purchase, then he earns commissions from his own purchase, which doesn't really make sense.
Solution
To solve above issues I propose:
- To move commission calculation code from "order approval method" to "affiliate statistics reset method"
- Don't consider affiliate user login reason to create affiliate association. In fact if one affiliate makes purchase using another affiliate code, then another affiliate (code owner) should get credit for that.
Pros:
- administrator/affiliate don't see any intermediate commissions that might be different once affiliate plan period is over
- actual commission % (from affiliate plan) is determined once per period, which reduces error factor greatly
Cons:
- until affiliate plan period is over nobody knows what is earned by each affiliate, because we only see that a particular order has affiliate association and nothing more