stop notify to referrer for some product no commission.

I have two category of product 1- for paid member the products of these category no commission set for affiliates and 2- for general customer i set referral rate for it. Now when a member buy some product that no commission the email sent to affiliate is 0$ so i need to stop notify to referrer for some category of product that is no commission .
Former times I use this function :

add_action( ‘init’, ‘init_no_zero_notifications’ );

function init_no_zero_notifications() {
add_action( ‘affiliates_referral’, ‘no_zero_notifications’, 9 );
add_action( ‘affiliates_updated_referral’, ‘no_zero_notifications’, 9 );
}

function no_zero_notifications( $referral_id ) {
global $wpdb;
$referrals_table = _affiliates_get_tablename( ‘referrals’ );
$amount = $wpdb->get_var( $wpdb->prepare( “SELECT amount FROM $referrals_table WHERE referral_id = %d”, $referral_id ) );
if ( floatval( $amount ) <= 0 ) {
remove_action( ‘affiliates_referral’, array( ‘Affiliates_Notifications’, ‘affiliates_referral’ ) );
remove_action( ‘affiliates_updated_referral’, array( ‘Affiliates_Notifications’, ‘affiliates_updated_referral’ ) );
}
}

but now it’s not working i don’t how.
note : i use woocommerc.

thank you.

10 Responses to stop notify to referrer for some product no commission.

  1. George March 7, 2017 at 9:15 am #

    Perfect! 🙂

  2. subhee March 4, 2017 at 7:04 am #

    I have tested it as your suggestion, it run well without any notifications on the test site.
    Thank you so much for your supports. However, I will try to find the problem in my live site

    Thank You
    Subhe

  3. George March 3, 2017 at 10:41 am #

    Hi subhee,

    I’ve created a test product with zero commission and a test affiliate.
    I’ve also added the snippet to a separate plugin because your functions.php file is not editable.
    I’ve recorded a referral and normally i didn’t receive any notifications.

    Please make a test affiliate and repeat my test.
    It’s working as it should on the test site, so probably on your live site, there is something else that prevents it from triggering.

    For further assistance you are always welcome to ask.

    Cheers

  4. George March 2, 2017 at 7:53 am #

    If it’s possible, deactivate the plugin(s) in question and try again.
    I haven’t received your email yet, please check whether it is blacklisted in http://www.sorbs.net/lookup.shtml.
    Alternatively, you can send your credentials to gtsiokos at gmail dot com.

    Cheers

  5. subhee March 1, 2017 at 12:48 pm #

    When i enabled debugging i can’t make test order and it showing many bug from another plugin. I sent the dashboard admin user to your mail. please help

    Thank you more.

  6. George February 28, 2017 at 7:24 pm #

    Hi subhee,

    Try enabling debugging and see if there is anything logged in your debug.log file.
    In order to enable debugging, go to your wp-config.php file and replace the following line:

    define(‘WP_DEBUG’, false );

    with these lines:
    define(‘WP_DEBUG’, true );
    define(‘WP_DEBUG_LOG’, true );

    then add a file named debug.log to your wp-content folder and make a test referral. If you like i can have a look at your dashboard. You can send me temporary admin access to george at itthinx dot com.

    Cheers,
    George

  7. subhee February 28, 2017 at 2:04 pm #

    I can’t resolve it and I’m sure that i placed the snipped to correct place because i usually use it. if can’t solve it i will test your plugin with another web maybe the problem from some plugin.
    thank you.

  8. George February 27, 2017 at 7:01 pm #

    Sure, if you don’t resolve it, let me know.
    Please also double check that the snippet is placed at the functions.php file of your active theme.

    FYI the links from the documentation i posted, describe how these hooks work. For general info on hooks, please have a look at the WP codex for hooks.

    Cheers

  9. subhee February 27, 2017 at 2:28 am #

    Hi George I tried this snipped to function.php but still not working. I have tested two time but the mail notification still sent to referrer. And i don’t know how to make action hook. I will send a user to check in my web if there have something wrong.

  10. George February 26, 2017 at 4:42 pm #

    Hi subhee,

    Please try the snippet below.
    You can get the amount value directly from the params array, so there is no need to retrieve data from the DB. Also, please note that affiliates_updated_referral action hook get different parameters than the affiliates_referral action hook. You can see the full description in the documentation.

    add_action( 'init', 'init_no_zero_notifications' );

    function init_no_zero_notifications() {
    add_action( 'affiliates_referral', 'no_zero_notifications', 9, 2 );
    }

    function no_zero_notifications( $referral_id, $params ) {

    if ( floatval( $params['amount'] ) <= 0 ) {
    remove_action( 'affiliates_referral', array( 'Affiliates_Notifications', 'affiliates_referral' ) );
    remove_action( 'affiliates_updated_referral', array( 'Affiliates_Notifications', 'affiliates_updated_referral' ) );
    }
    }

    Kind regards,
    George

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

Share