PDA

View Full Version : Merging with phpcoin


quillspirit
9th July 2004, 08:06 AM
Hello,
I am trying to merge Post Affiliate Pro 2.2.1 with the current version of phpCOIN (phpcoin.com) - In the order form, there is a text field for the customer to type in the name of the person that referred them. I was wondering how I could "pre-fill" that field with the affiliate id, if they came in through an affiliate link.

I found this in one of the php function files for phpCOIN, thought it may help...


$_cstr .= '<INPUT TYPE=hidden name="ord_referred_by" value="'.$adata[ord_referred_by].'">'.$_nl;


I have Affiliate Pro setup to hold a cookie, and all affiliate links go to my .html index page... so I guess I would need to read the cookie to get the affiliate id, then insert into the form field above, which is on a .php order page. How do I do this?

Thanks! :)

mark
11th July 2004, 11:04 AM
Hello,

getting cookie in PHP is quite easy:

if(isset($_COOKIE['POSTAff2Cookie']) && $_COOKIE['POSTAff2Cookie'] != '')
$cookieval = $_COOKIE['POSTAff2Cookie'];

if($cookieval == '')
return; // cookie is not set

$arr = split ( '_', $cookieval);

if(!is_array($arr) || count($arr) != 2 || !is_numeric($arr[0]) || !is_numeric($arr[1]))
return; // cookie is not in correct format

$affiliateID = $arr[0];
$campaignID = $arr[1];


As you can see, the cookie itself contains two varialbes, affiliate ID, and ID of campaign (product category). You need to make a simple operation (see above) to get only affiliate ID.

Be avare of the returns if cookie is not set or is in bad format.
Maybe you dont want to return from the script, so you should customize the if conditions accordingly.

hope it helped,

mark