Your cart is currently empty!
Manual referral for a subscription
—
by
I have a subscription that did not get assigned to any affiliate. I know the affiliate the referred this customer and I need to create a referral that gets associated with the order/subscription moving forward. I want to make sure further renewals are attributed to the affiliate properly and automatically. I feel like I did this years ago but can’t figure it out now?
Posted in Affiliates Enterprise
Comments
3 responses to “Manual referral for a subscription”
That’s great Michael!
Cheers
This worked like a charm, thank you!
I did already have the recurring referrals option enabled.
Hi Michael,
Welcome back to our support forum for Affiliates Enterprise.
You can add a referral programmatically, but prior to that please check your referrals under Affiliates > Referrals, just in case a referral has been recorded for that order and has been credited to the Direct. If there is one, you can simply edit it and specify the correct affiliate to the first field.
Otherwise, you can run the following snippet only once and after specifying a few details for that referral, such as the affiliate that should be credited, the commission amount and the order id involved.
$affiliate_ids = array( 2 ); // array of affiliate ids
$net_amount = 100; // commission amount
// appropriate currency code for the referral
$currency = 'USD'; // or similar valid currency code
// related post ID, order ID, ...
$post_id = 1234; // order_id
$description = sprintf( 'Order #%s', $post_id );
$data = array(
'order_id' => array(
'title' => 'Order #',
'domain' => 'affiliates',
'value' => esc_sql( $post_id )
),
'order_total' => array(
'title' => 'Total',
'domain' => 'affiliates',
'value' => esc_sql( $net_amount )
),
'order_currency' => array(
'title' => 'Currency',
'domain' => 'affiliates',
'value' => esc_sql( $currency )
)
);
$r = new Affiliates_Referral_WordPress();
$r->add_referrals( $affiliate_ids, $post_id, $description, $data, null, $net_amount, $currency, 'accepted', 'sale', null );
Reference:
– https://docs.itthinx.com/document/affiliates-enterprise/api/referrals/
Also, for recurring referrals to be triggered, you need to enable the necessary option in Affiliates > WooCommerce Integration(if not already enabled), right at the bottom of this options page.
Kind regards,
George