apply_filters( 'wcml_raw_price_amount', integer/float $price, string $currency )
- Type
- filter
- Category
- Multi-currency Feature
- WooCommerce Multilingual Version
- 3.5
Description
- Convert the raw price in the default currency into the selected currency.
- This filter should be used for filtering product/variations prices in general.
- It is available on the front-end.
This filter is applied to the custom fields of products and variations that are used for prices (when they are read from the database):
- _price
- _regular_price
- _sale_price
- _min_variation_price
- _min_variation_price_regular_price
- _mix_variation_price_sale_price
- _max_variation_price
- _max_variation_price_regular_price
- _max_variation_price_sale_price
Arguments
- $price
- (integer/float) (Required) The raw price in the default currency.
- $currency
- (string) (Optional) The currency code you want to convert the price into, e.g. “USD”, “EUR”, etc. If this parameter is not set, the current currency used on the front-end will be used.
Example usage
Example
/*
Assume:
* USD = the default currency
* EUR = the second currency
* 0.8 = the exchange rate USD / EUR
*/
$price = 100;
$currency = "EUR";
$new_price = apply_filters('wcml_raw_price_amount', $price, $currency);
echo $new_price; // Return 80
Related hooks
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