benecaster_get_referral_credit_cents()
Returns the current pending referral credit balance in cents.
Access: Free (can be called from any context)
Since: feature/refer-a-friend-admin
Signature
benecaster_get_referral_credit_cents(): int
Return Value
An integer representing the earned-but-not-yet-applied referral credit balance in cents, as reported by the last /validate response. Returns 0 when the option is absent, when the referrer has no pending credit, or when the license server feature/referral-program batch has not yet shipped.
This function always returns an integer (never null). Returns 0 on free/Launch installs and unlicensed sites.
This function reads from the locally cached benecaster_license_referral_credit_cents option — no HTTP call. Refreshed during each daily validation run; cleared on deactivation or invalid validation.
Usage
// Show a credit notification when balance exceeds a threshold
add_action( 'admin_notices', function(): void {
$cents = benecaster_get_referral_credit_cents();
if ( $cents < 500 ) { // less than $5.00
return;
}
printf(
'<div class="notice notice-info"><p>You have $%.2f in Benecaster referral credit pending.</p></div>',
$cents / 100
);
} );
// Include credit balance in an external monitoring payload
add_action( 'benecaster_license_validated', function(): void {
$cents = benecaster_get_referral_credit_cents();
if ( $cents === 0 ) {
return;
}
// report $cents / 100 as a dollar amount to monitoring system
} );
Notes
- The balance reflects earned credit that has not yet been applied to a renewal invoice. The license server drips the credit at up to 50% of the renewal amount per billing cycle until the full balance is exhausted.
- The value is updated on each daily validation run. If a referral converted since the last validation, the balance will not reflect it until the next run.
- To display as dollars:
number_format( benecaster_get_referral_credit_cents() / 100, 2 ).
Related
benecaster_get_referral_code()— returns the raw referral codebenecaster_get_referral_link()— returns the full referral URL- Refer a Friend — customer-facing explanation of how credits are earned and applied