add_filter( 'wcml_client_currency', 'the_callback_function', 10, 1 );
- Type
- filter
- Category
- Multi-currency Feature
- WooCommerce Multilingual Version
- 3.5
Description
Filter the currency set by the user on the front-end.
If the currency is changed in the filter, we strongly recommend you force the page to reload. This prevents inconsistencies in the way currencies are displayed. Otherwise, if the currency is changed too late, part of the application state could be in one currency, and the rest in another one.
Arguments
There is only one parameter passed to this filter: currency.
- $currency
- (string) The code of the currency used on the front-end, e.g. “USD”, “EUR”, etc.
Example usage
Example
/**
* Add this code to the functions.php file of your theme.
*/
add_filter( 'wcml_client_currency', 'modify_client_currency', 10, 1 );
function modify_client_currency( $currency ) {
return 'USD';
} Related hooks
wcml_custom_prices_fields_labels, wcml_is_cache_enabled_for_switching_currency, wcml_geolocation_get_user_country, wcml_user_store_strategy, wcml_rounded_price, wcml_currencies_without_cents, wcml_product_custom_prices, wcml_custom_prices_strings, wcml_switch_currency, wcml_custom_prices_fields