If you are a plugin developer and want to integrate your plugin with the WP Affiliate platform plugin then you can use the action hook mentioned in this documentation to do so.
This documentation is only for WordPress plugin developers. If you are not a WordPress plugin developer then you have no need to read this.
Awarding Commission From Another WordPress Plugin or Theme Using a Hook
When you want to award the commission from your plugin (for example: after a payment is confirmed or after a user submits the contact form) you can simply use the following code block (and pass in the required details). The affiliate plugin will credit the appropriate affiliate account:
$sale_amt = "19.95"; //TODO - The commission is calculated based on this amount $unique_transaction_id = "Txn-ID"; //TODO - The unique transaction ID for reference $email = "Buyer-email-goes-here"; //TODO - Customer email for record $referrer = $_COOKIE['ap_id'];//Cookie value is read from the customer's browser do_action('wp_affiliate_process_cart_commission', array("referrer" => $referrer, "sale_amt" =>$sale_amt, "txn_id"=>$unique_transaction_id, "buyer_email"=>$email));
You only need to adjust the values in the first 3 lines of the above example code (marked with “TODO” comments)
How To Get Referrer ID (Affiliate ID)
There are two ways to get the referrer ID value (use one of the following options):
Option 1: The referrer value is stored in the browser’s cookie by the affiliate plugin and you can access it like the following:
$referrer = $_COOKIE['ap_id'];
If you need to pass the referrer value to a back-end post payment processing script (example: a payment notification handling script) then you can add this cookie value to the custom field.
Option 2: If you know the IP address of the user then you can call the following function and pass in the IP address. This function will return the referrer ID for that user (if any):
$referrer = wp_aff_get_referrer_id_from_ip_address($ip_address)