WPML
wcml_geolocation_get_user_country
类型
filter
WooCommerce Multilingual 版本
4.11.0

说明

允许覆盖 WCML 地理定位的国家

参数

$userCountry
(字符串) 如果已设置,则使用账单地址,否则使用地理定位国家/地区。
$allUserCountries
(数组) {
@key $billing
(字符串) 账单地址所在国家/地区
@key $shipping
(字符串) 收货地址所在国家/地区
@key $geolocation
(字符串) 地理定位国家/地区
}

使用示例

// Always use the shipping address if it's available
add_filter( 'wcml_geolocation_get_user_country', function( $userCountry, $allCountries ) {
    return ! empty( $allCountries['shipping'] ) ? $allCountries['shipping'] : $userCountry;
}, 10, 2 );

wcml_custom_prices_fields_labels, wcml_is_cache_enabled_for_switching_currency, 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, wcml_multi_currency_ajax_actions

所有 24 个 多货币功能 钩子 →