Cap the Commission Per Referral (AffiliateWP)
Limits how much commission any single referral can earn, so a very large order does not produce an outsized payout.
Opens WPIDE on
Code
$wpide_max_commission = 200; // Maximum commission per referral.
add_filter( 'affwp_calc_referral_amount', function ( $amount ) use ( $wpide_max_commission ) {
return min( (float) $amount, (float) $wpide_max_commission );
} );
Notes
Set $wpide_max_commission in your store currency. Referrals already recorded are not changed.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.