Hooks, filters, and constants in Payment Gateway Currency #
Payment Gateway Currency for WooCommerce exposes filters and actions so developers can adjust conversion behavior, rates, restriction logic, and frontend output in code. All names below are verified against the plugin source (Pro v4.1.5). Option keys use the alg_wc_pgbc_ prefix, except the Restrict section, which keeps legacy alg_wc_payment_gateways_by_currency_ keys.
Filters #
| Filter | Arguments | Purpose |
|---|---|---|
alg_wc_pgbc_pre_check |
$do_check (bool) |
Whether a gateway is eligible for Restrict Currency. Free returns true only for the standard gateways; Pro sets it to __return_true for all. |
alg_wc_pgbc_settings |
$value, $type, $args |
Pro gating filter for settings field attributes. In Free it injects the disabled attribute on non-standard gateways. |
alg_wc_pgbc_convert_currency_do_convert |
$do_convert (bool) |
Final say on whether conversion runs for the current request (cart, checkout, AJAX). |
alg_wc_pgbc_convert_currency_get_gateway_rate |
$rate, $gateway, $obj |
The conversion rate resolved for a gateway (false if none). Override to compute rates dynamically. |
alg_wc_pgbc_convert_currency_rate |
$rate, $from, $currency |
Each rate fetched from a server, after the Multiplier is applied, before it is stored. |
alg_wc_pgbc_server_rates_function |
$callable |
The callback used to fetch rates from the selected server. Return your own callable to add a rate source. |
alg_wc_pgbc_convert_currency_get_shop_currency |
$currency |
The shop currency recorded in the conversion data for an order or session. |
alg_wc_pgbc_do_convert_shipping_package_rate |
$do_convert, $method_id |
Whether to convert a specific shipping package rate. Return false to skip a method. |
alg_wc_pgbc_convert_currency_info_get_output_placeholders |
$placeholders, $position, $obj |
The placeholder map used to render a frontend info position. Add or change placeholders here. |
alg_wc_pgbc_convert_filterable_scripts_l10n |
$l10n, $handle, $object_name |
Localization data passed to the plugin’s filterable frontend script. |
Actions #
| Action | Fires when |
|---|---|
alg_wc_pgbc_settings_saved |
A settings section is saved. Used internally to trigger a manual rate update. |
alg_wc_pgbc_version_updated |
The stored plugin version differs from the running version (on upgrade). |
Constants #
Set a rate-server API key in wp-config.php instead of the settings screen using ALG_WC_PGBC_API_KEY_{SERVER}, uppercased. For Fixer.io:
define( 'ALG_WC_PGBC_API_KEY_FIXER', 'your-fixer-api-key' );
When the constant is defined, the corresponding server key field is hidden and the constant value is used.
Examples #
Apply Restrict Currency logic to all gateways without Pro’s blanket override, for a single gateway:
add_filter( 'alg_wc_pgbc_pre_check', function( $do_check ) {
// Return true to run allowed/denied checks for the current gateway.
return $do_check;
} );
Nudge every auto-fetched rate up by a fixed amount in code:
add_filter( 'alg_wc_pgbc_convert_currency_rate', function( $rate, $from, $currency ) {
return (float) $rate * 1.02;
}, 10, 3 );
Skip conversion of a specific shipping method:
add_filter( 'alg_wc_pgbc_do_convert_shipping_package_rate', function( $do_convert, $method_id ) {
return ( 'local_pickup' === $method_id ) ? false : $do_convert;
}, 10, 2 );
Need a hand? #
Our team answers every ticket on the Payment Gateway Currency support forum.