add_filter( 'wcml_client_currency', 'the_callback_function', 10, 1 );
- 类型
- filter
- 类别
- 多货币功能
- WooCommerce Multilingual 版本
- 3.5
说明
过滤用户在前端设置的货币。
如果在过滤器中更改了货币,我们强烈建议您强制重新加载页面。这可以防止货币显示方式出现不一致。否则,如果货币更改得太晚,应用程序的部分状态可能会使用一种货币,而其余部分则使用另一种货币。
参数
传递给此过滤器的参数只有一个:currency。
- $currency
- (字符串)在前端使用的货币代码,例如“USD”、“EUR”等。
使用示例
示例
/**
* 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';
} 相关钩子
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