# 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.

- Type: PHP
- Runs: Run everywhere
- Category: [Plugin Integrations](https://wpide.com/library/category/integrations/)
- Tags: affiliatewp, commissions, limits
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/affwp-cap-referral-amount/

## Code

```php
$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 use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Cap the Commission Per Referral (AffiliateWP)" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
