I have a bit of a sticky problem I could really do with some help with.
I’m building a charity app which has a refer-a-friend invite option (this uses a unique referral code attributed to each user at sign-up who sends the referral code to someone they want to invite to the app).
The reason I use a unique referral code is I want the actions (money donated etc) of the referred (the child) to be attributed to the inviter (the parent).
However, I just can’t figure out a way to attribute the actions of one user to another user.
I have a user collection (obviously) with a ‘ReferralCode’ field and a ‘ParentReferralCode’ (the parent referral code, if there is one, is filled in as part of the sign-up process).
I also have a ‘MyGivingActions’ field which records money the user donates.
The key issue I need help to figure out is how to update a ‘ChildGivingTotal’ field which will record the giving of my ‘children’ (and their children).
The child is linked to the parent by the referral code, but how can I update the ‘ChildGivingTotal’ of another user (my parent)??
I’ve been trying to figure this out for a couple of days…I’m stuck, like properly stuck!