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
https://forums.phpfreaks.com/topic/46659-solved-help-with-snipit/
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

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 );
}

}

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.