Pap_Api_Affiliate

Row object means class representing one affiliate record. You can use it to retrieve, edit and add affiliates.


Methods:

load() - loads record with given user id or other parameters. You have to set at least one field before calling this method.
Note: If you try to load some affiliate data, you must first setup data to load from, for example username, then call load method and after that all other available informations will be available to you.

save() - save changes in given record (record must be loaded first).

add() - inserts new record

getMessage() - returns error message in case of error


assignToPrivateCampaign($campaignID) assigns the affiliate to private campaign.

sendConfirmationEmail() – sends the affiliate confirmation signup email

enableCreateSignupReferralCommissions() – create signup and referral commission.


The following methods get/set the corresponding fields:

getUserid(), setUserid($value)

getRefid(), setRefid($value), setRefid($value, $operator) – as $operator parameter you can use Pap_Api_Affiliate::OPERATOR_EQUALS or Pap_Api_Affiliate::OPERATOR_LIKE (by default is used operator like)

getParentUserId(), setParentUserId($value)

getUsername(), setUsername($value), setUsername($value, $operator) – as $operator parameter you can use Pap_Api_Affiliate::OPERATOR_EQUALS or Pap_Api_Affiliate::OPERATOR_LIKE (by default is used operator like)

setPassword($value)
Note: Do NOT use method setPassword as one of the parameters when loading affiliate. Loading affiliate by his password is not permitted (reasonable).

getFirstname(), setFirstname($value), setFirstname($value, $operator) – as $operator parameter you can use Pap_Api_Affiliate::OPERATOR_EQUALS or Pap_Api_Affiliate::OPERATOR_LIKE (by default is used operator like)

getLastname(), setLastname($value), setLastname($value, $operator) – as $operator parameter you can use Pap_Api_Affiliate::OPERATOR_EQUALS or Pap_Api_Affiliate::OPERATOR_LIKE (by default is used operator like)

getStatus(), setStatus($value) – allowed values: A – approved, P – pending, D - declined

getNote(), setNote($value) – note about the affiliate

getPhoto(), setPhoto($value) – URL to the file with photo

getIp() , setIp($value) Works only with save() method. So you can use it only after you load() an affiliate.

getMinimumPayout() , setMinimumPayout($value)

getNotificationEmail(), setNotificationEmail($value)

getPayoutOptionId(), setPayoutOptionId($value)

setPayoutOptionField($code, $name)


There are another three special methods related to the way PAP handles affiliate information.

Every affiliate has up to 25 custom fields named data1, data2, ... data25. These fields are configurable, and you can use them to store any information about affiliate.

For example data1 can be Street, data2 = City, etc.

You can edit these assignments in

merchant panel -> Configuration -> Affiliate signup -> Fields.


Special methods:

getData($index), setData($index, $value), setData($index, $value, $operator) gets/sets data value given in $index variable, as $operator parameter you can use Pap_Api_Affiliate::OPERATOR_EQUALS or Pap_Api_Affiliate::OPERATOR_LIKE (by default is used operator like)

getDataName($index) – returns assigned name of the data in given index (index can be: 1 to 25), for example “Street” for data1. It returns empty string for undefined field.

getDataStatus($index) – returns status of data field in given index (index can be: 1 to 25), available values: M – mandatory, O – optional, U - hidden/readonly

setVisitorId($value) – can be used for loading complete information about the affiliate from the cookies


Example using affiliate object:

//----------------------------------------------
// get affiliate with userid = b7ab1580

$affiliate = new Pap_Api_Affiliate($session);
$affiliate->setUserid("b7ab1580");
try {
$affiliate->load();
} catch (Exception $e) {
die("Cannot load record: ".$affiliate->getMessage());
}
echo "Affiliate ".$affiliate->getFirstname()." ".$affiliate->getLastname()." loaded<br>";

//----------------------------------------------
// now we'll change first name and save the change
$affiliate->setFirstname("John");
try {
if ($affiliate->save()) {
echo "Affiliate saved successfuly";
} else {
die("Cannot save affiliate: ".$affiliate->getMessage());
}
} catch (Exception $e) {
die("Error while communicating with PAP: ".$e->getMessage());
}

//----------------------------------------------
// inserting new affiliate
// the mandatory fields might differ depending
// on your settings in the merchant panel at Configuration > Affiliate signup > Fields (tab)

$affiliate = new Pap_Api_Affiliate($session);
$affiliate->setUsername("some@email.com");
$affiliate->setFirstname("John");
$affiliate->setLastname("Smith");

try {
if ($affiliate->add()) {
echo "Affiliate saved successfuly";
} else {
die("Cannot save affiliate: ".$affiliate->getMessage());
}
} catch (Exception $e) {
die("Error while communicating with PAP: ".$e->getMessage());
}
NOTE I.: You can find the userid of an affiliate via the following API:
http://support.qualityunit.com/608550-Pap_Api_AffiliatesGrid

NOTE II.: Do not forget to initiate an API session (log in as merchant via API) as shown here.
Quality Unit's products

LiveAgent

LiveAgent integrates live chat software and help desk software features into a single customer support solution.

Try it free

Post Affiliate Pro

Post Affiliate Pro is a full featured affiliate tracking software ready to power your own affiliate program.

Buy Now