WPML
add_filter( 'wcml_rounded_price', 'the_callback_function', 10, 2 );
类型
filter
WooCommerce Multilingual 版本
4.0.0

说明

  • 在应用舍入规则后筛选第二货币价格。
  • 这些规则在 WooCommerce -> WPML Multilingual & Multicurrency for WooCommerce 页面的多货币选项卡下设置。

参数

传递给此过滤器的参数有两个:
$price
(整数) 应用舍入规则后的价格。
$currency
(字符串) 第二货币代码,例如“USD”、“EUR”等。

使用示例

示例
/*
 * Add this code to the functions.php file of your theme.
 *
 * Assume: 
 * USD = the default currency
 * EUR = the second currency
 */
  
add_filter( 'wcml_rounded_price', 'wcmlhook_rounded_price', 10, 2 );

function wcmlhook_rounded_price( $price, $currency ) {
	if ( 'EUR' == $currency ) {
		$price = $price + 0.99; // Add 99 cents to all rounded prices
	}

	return $price;
}

wcml_custom_prices_fields_labels, wcml_is_cache_enabled_for_switching_currency, wcml_geolocation_get_user_country, wcml_user_store_strategy, 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 个 多货币功能 钩子 →