Jump to content

affiliate program script change


manula

Recommended Posts

Hi there,

I'm going crazy over this piece of code. I'm a newbie of php and I can't get my head around this.
I know what I'm trying to do is quite simple but nothing I've tried works. Perhaps someone out there can point me in the right direction!

This is a an extract of a script I own and have the right to change. The behaviour I'm trying to change is:
- currently - website members do not earn any points or cash commission for new FREE members they sponsor.

- I want - website members to still earn any points or cash commission for new FREE members they sponsor.

As you can see below the script has 4 membership levels. The variables we need to work on are 'AFF_RATES_FOR_LEVELS' and 'AFF_POINTS_FOR_LEVELS'

Here's the code. Thanks in advance for trying to help.
Regards


[code]function affiliate($err_msg = '', $user = '') {
$q =& $this->Common->q;
$db =& $this->Common->db;
$tpl =& $this->Common->tpl;
$vars = array();

if ($user == '') $user = $this->_check_login();
$allow = 0;
foreach (array('Free', 'Pro', 'Premium', 'Executive') as $membership) {
    if (strtolower($this->cfg->AFF_MEMBERSHIP) == strtolower($membership)) $allow=1;
    if ($user['Membership'] == $membership) break;
}
if (!$allow) {
    $err_msg = "No affiliate program for ${user['Membership']} users.  You can upgrade to ".$this->cfg->AFF_MEMBERSHIP." account here.";
    $this->membership($err_msg, $user);
    exit;
} else {
    $aff_rates = array();
    $level = 0;
    foreach ($this->Common->aff_rates($user['Membership']) as $_) {
    array_push($aff_rates, (substr($_,-1) == '%' ? $_ : '$'.number_format($_/100,2)).' (for level '.$level++.')');
    }
    $vars['AFF_RATES_FOR_LEVELS'] = count($aff_rates) ? $this->Common->specialchars(join(', ', $aff_rates)) : '<NO COMMISSIONS>';
    $aff_points = $this->Common->aff_points($user['Membership']);
    $aff_points2 = array();
    if (count($aff_points)) {
$level = 0;
foreach ($aff_points as $_) {
array_push($aff_points2, number_format($_,0).' (for level '.$level++.')');
}
$vars['AFF_POINTS_FOR_LEVELS'] = count($aff_points) ? $this->Common->specialchars(join(', ', $aff_points2)) : '<NO POINTS>';
    }
    $aff_points = $this->Common->aff_points_for_point_purchases($user['Membership']);
    $aff_points2 = array();
    if (count($aff_points)) {
$level = 0;
foreach ($aff_points as $_) {
array_push($aff_points2, $_.' (for level '.$level++.')');
}
$vars['AFF_POINTS_FOR_POINT_PURCHASES_FOR_LEVELS'] = count($aff_points) ? $this->Common->specialchars(join(', ', $aff_points2)) : '<NO POINTS>';
    }
    $vars['AFF_URL'] = $this->cfg->BASE_URL.'/g.'.$this->cfg->SCRIPT_EXTENTION."?r=${user['ID']}";
    $vars['ERR_MSG'] = $err_msg;
    $vars["Membership_${user['Membership']}"] = 1;
    $_ = array();
    if (trim($this->cfg->POINTS_PER_MONTH) != '') {
# get right Free..Executive order
$_ = array('Free'=>0,'Pro'=>0,'Premium'=>0,'Executive'=>0,);
list( $_["Free"], $_["Pro"], $_["Premium"], $_["Executive"] ) = preg_split('/[\s,]+/', trim($this->cfg->POINTS_PER_MONTH), -1, PREG_SPLIT_NO_EMPTY);
if ($_[$user['Membership']]) {
    $vars['POINTS_PER_MONTH_FOR_USER'] = $_[$user['Membership']];
    $vars['MONTHLY_Membership'] = $user['Membership'];
}[/code]
Link to comment
https://forums.phpfreaks.com/topic/24187-affiliate-program-script-change/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.