Manual referral for a subscription

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?

3 Responses to Manual referral for a subscription

  1. George April 3, 2024 at 6:34 am #

    That’s great Michael!


  2. Michael April 2, 2024 at 3:42 pm #

    This worked like a charm, thank you!

    I did already have the recurring referrals option enabled.

  3. George April 2, 2024 at 3:20 pm #

    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 );

    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,

We use cookies to optimize your experience on our site and assume you're OK with that if you stay.
OK, hide this message.

Affiliates · Contact · Jobs · Terms & Conditions · Privacy Policy · Documentation · Downloads · Useful Plugins · My Account