WPML
apply_filters( 'wcml_formatted_price', integer/float $price, string $currency )
类型
filter
WooCommerce Multilingual 版本
3.5

说明

将默认货币价格转换为所选货币,并使用正确的格式。

参数

$price
(integer/float) (必填) 默认货币的原始价格。
$currency
(字符串) (可选) 您要将价格转换成的货币代码,例如“USD”、“EUR”等。如果未设置此参数,则将使用前端当前使用的货币。

使用示例

示例
/*
Assume: 
 * EUR = the default currency
 * USD = the second currency
 * 1.2 = the exchange rate EUR / USD 
*/ 

$price = 1234.56;
$currency = 'USD';
$formatted_price = apply_filters( 'wcml_formatted_price', $price, $currency );

echo $formatted_price; // Return $1,481.47

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

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