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?


Comments

3 responses to “Notifications with referral amount”

  1. Eugen Bleck Avatar
    Eugen Bleck

    Hi Yvonne,

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

    Happy weekend, warm regards,
    Eugen.

  2. Many thanks. Happy New Year.

  3. Eugen Bleck Avatar
    Eugen Bleck

    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.

Share