apply_filters( 'wcml_product_price_by_currency', integer $product_id, string $currency )
- 类型
- filter
- 类别
- 多货币功能
- WooCommerce Multilingual 版本
- 3.9
说明
- 如果已输入自定义价格,此钩子将返回该价格。否则,它将返回基于设定汇率的价格。
- 此钩子仅在前端生效。
参数
- $product_id
- (整数) (必填) 产品 ID
- $currency
- (字符串) (必填) 您希望获取其价格的货币代码,例如“USD”、“EUR”等。
使用示例
示例
// Get the EUR price of the product ID = 80 $product_id = 80; $currency = 'EUR'; echo apply_filters( 'wcml_product_price_by_currency', $product_id, $currency );
请注意:多货币代码并不总是加载。如果您发现此过滤器不起作用,请查看 wcml_load_multi_currency_in_ajax 钩子。
相关钩子
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