Jump to content

[SOLVED] Help with snipit


jimmyp3016

Recommended Posts

Hey Guys,

 

Trying to figure this one out. I have this function below.

 

function doCommision() {
if ($user->jv == 'y')
{
define( "AFFILIATE_COMMISSION", 20 );
} else {
define( "AFFILIATE_COMMISSION", 10 );
}

}

 

So basically if the user is a jv partner, the affiliate commisions are higher.

 

I have a user that is a jv partner but it says he earns 10 when he should earn 20. I even echo'd the page for the jv variable and it says y.

 

Users who jv is N show 10 which is the correct amount.

 

Can you tell me what im doing wrong?

Link to comment
Share on other sites

I wouldn't store a string for simple comparison.  I think it'd be more logical to use a boolean value.  Too many things can go wrong with strings, such as extra whitespace or capital letters, etc, etc.  If you can't change it to a boolean, then try checking strtolower(trim($user->jv)) rather than just $user->jv

Link to comment
Share on other sites

I think the problem is that the $user object is a global variable and cannot be accessed from within the function.

 

try either

 

function doCommision() {
global $user;
if ($user->jv == 'y')
{
define( "AFFILIATE_COMMISSION", 20 );
} else {
define( "AFFILIATE_COMMISSION", 10 );
}

}

or

 

function doCommision($user) {

if ($user->jv == 'y')
{
define( "AFFILIATE_COMMISSION", 20 );
} else {
define( "AFFILIATE_COMMISSION", 10 );
}

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.