Notifications with referral amount

When I use the placeholder shortcode [referral_amount] in an email notification it looks like this: “A referral of EUR 1.500000 has been credited to …”. Is there a way to limit the number of digits after the decimal point to 2?

3 Responses to Notifications with referral amount

  1. Eugen Bleck January 4, 2020 at 4:07 pm #

    Hi Yvonne,

    I am glad I could be of help. Thanks for using our plugins.

    Happy weekend, warm regards,
    Eugen.

  2. Yvonne January 4, 2020 at 3:45 pm #

    Many thanks. Happy New Year.

  3. Eugen Bleck January 3, 2020 at 7:41 pm #

    Hello Yvonne,

    Happy new year and thanks for being a valued customer. Please add the following code snippet to your wp-config.php file;
    define( 'AFFILIATES_REFERRAL_AMOUNT_DECIMALS_DISPLAY', 2 );. The shortcode will format the amount return by the [referral_amount] to 2 decimal places.

    Then add this to your functions.php file


    add_filter( ‘affiliates_notifications_tokens’, ‘example_affiliates_notifications_tokens’ );

    function example_affiliates_notifications_tokens( $tokens ) {

    if ( isset( $tokens[‘referral_amount’] ) ) {

    $tokens[‘referral_amount’] = bcadd( $tokens[‘referral_amount’], 0, affiliates_get_referral_amount_decimals() );

    }
    return $tokens;
    }

    #Note: AFFILIATES_REFERRAL_AMOUNT_DECIMALS_DISPLAY constant can be used to modify the decimals used for display.

    Thanks again for using our plugins. I wish you a fun and exciting weekend.

    Kindest regards,
    Eugen.

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