The woocs_add_custom_rate filter changes a currency rate on the fly, after FOX has resolved it and before it is used. Available from v.2.3.1 / 1.3.1.
Unlike the aggregator pair, this needs no registration and no settings entry — it simply intercepts the number. It is the shortest route to a margin on top of the market rate, or to rates driven by your own logic entirely.
add_filter('woocs_add_custom_rate', function ($rate, $currency) {
if ($currency === 'EUR') {
return floatval($rate) * 1.03; // 3% on top of the market rate
}
return $rate;
}, 10, 2);
Parameters:
$rate - the rate FOX resolved
$currency (string) - the currency code
Returns:
Note: for a plain percentage margin there is no need for code at all — the interes field in the currency settings does the same thing. Use this filter when the adjustment depends on something the settings cannot express: the time of day, the user role, a value from an external system.