Your cart is currently empty!
Notifications with referral amount
—
by
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?
Posted in Affiliates by Username
Comments
3 responses to “Notifications with referral amount”
Hi Yvonne,
I am glad I could be of help. Thanks for using our plugins.
Happy weekend, warm regards,
Eugen.
Many thanks. Happy New Year.
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.