Hey All,
I’m building a networking program that pays to 2 different types of affiliates. Affiliates with no product purchase earn only on their first tier. Affiliates with product purchases earn on all 7 seven tiers of their downline.
Since all affiliates earn on tier 1 we use 1 function to pay those commissions and start paying the rest of the upline at the next level up. I need to find a way to compress any missed commissions up to the next qualified affiliate.
Here’s my function here:
[php]
function payUpline ($member_id, $amount)
{
global $db, $pay_upline_array;
$time = time ();
$upline_member = $db->GetOne ("Select placement_id From `members` Where member_id='$member_id'", 0);
getReferralComission ($member_id, $amount);
foreach ($pay_upline_array as $percent)
{
$upline_member = $db->GetOne ("Select placement_id From `members` Where member_id='$upline_member'", 0);
$upline_level = $db->GetOne ("Select level_id From `members` Where member_id='$upline_member'", 0);
if ($upline_member > 0 and $upline_level != 1)
{
$comms = number_format($amount * $percent, 2);
$db->ExecuteSql ("Insert Into `cash_transfers` (transfer_date, amount, payer_id, payer_description, payee_id, payee_description, is_roi) Values ('$time', '$comms', '$member_id', 'Review Purchase Commission', '$upline_member', 'Review Purchase Commission', 0)");
$db->ExecuteSql ("Update `members` Set cash_balance=cash_balance+'$comms' Where member_id='$upline_member'");
}
}
}[/php]
[php]if ($upline_member > 0 and $upline_level != 1)[/php] The line above stops commissions being paid to affiliates who don’t qualify, but we’d like those commissions paid up to the next affiliate that qualifies.
It would seem that I could either increase the percentage called in the array by the precentage that was missed, or pay the qualified affiliate twice. Not sure which would be easier, but I would appreciate any help. We would much rather pay the commission to someone than have it break back to the company.
Thanks so much.
Josh