I have been working with an affiliate integration and was having trouble getting through the logic of the signup process and the way in which affiliates are assigned. (basically I want to use coupon codes that will potentially overwrite the affiliate to give credit to the owner of the coupon).
In the end, I think the problem I was having is due to what looks like an error in logic in the handle_affiliate_link() function defined in affiliate.php.
Line 264 - tries to check for ref in URL
// There is an affiliate type query item, check it for validity and then redirect
Line 292 - tries to check all if there is no REF
// We are here if there isn't a reference passed, so we need to check the referrer.
Shouldn't this be an elseif? The way is it is now, this section is run even when $_GET['ref'] is set.
Line 308 - Then when it defines the cookie - it tries to use $_GET['ref'], even though we are only supposed to be here if there was no $_GET['ref'], according to the comments at least.
AFFILIATE_SETNOCOOKIE adds a "noaffiliate_" cookie if no referrer was found. Does this mean that this new user will never be able to be credited to an affiliate? Or if this user then comes to the site via and affiliate link, will it then be given an affiliate?