Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Our next available supporter will start replying to tickets in about 7.79 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 14:00 9:00 – 14:00 9:00 – 14:00 9:00 – 14:00 9:00 – 14:00 -
- 15:00 – 18:00 15:00 – 18:00 15:00 – 18:00 15:00 – 18:00 15:00 – 18:00 -

Supporter timezone: Asia/Dhaka (GMT+06:00)

This topic contains 5 replies, has 2 voices.

Last updated by Prosenjit Barman 9 months, 3 weeks ago.

Assisted by: Prosenjit Barman.

Author Posts
January 18, 2024 at 1:56 pm #15200317

pavelZ-3

Good afternoon.
We have a website using three currencies. Euros, Pounds Sterling and Dollars. The base currency is Euro. The conversion is done automatically.
On the cart page I want to display the price of the product in Euros and in the selected currency.

For example, a product costs 10 Euros. When selecting GBP I want to see: 10eur (8.52gbp).
The problem is that I can't get the price of the item in the base currency.

January 19, 2024 at 8:37 am #15203367

Prosenjit Barman
Supporter

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hello There,
Thanks for contacting WPML Support.

I understand what you're looking for. Please note that by default, the WooCommerce Multilingual plugin does not support displaying the base price alongside the converted price. Typically, it allows for the display of only one currency or price at a time for each language setting.

However, you can accomplish your goal with custom coding. I recommend referring to the WooCommerce Multilingual hook guide, which provides useful information for customizing the plugin to fit your needs. The guide below should assist you in implementing the desired functionality.

- https://wpml.org/documentation/related-projects/woocommerce-multilingual/wcml-hooks-reference/

For your information, providing support for custom coding or solutions is beyond the scope of our support. Therefore, you can hire a professional developer, who specializes in custom WPML and its add-ons from here: https://wpml.org/contractors/

I hope you can understand. If there is anything else you need help with, please feel free to let me know. I will be happy to help.

Best regards,
Prosenjit

January 22, 2024 at 8:24 am #15209722

pavelZ-3

Thank you for providing this information. It has been helpful. But now I have a different one, I can get the price in different currencies, but for the base currency the price is displayed wrong.
I will try to describe more details:
If the Euro currency is selected, the price is output correctly - 100 Euros,
If the currency selected is Dollar, the price is 120 Euros and in brackets the price is 109.14 dollars. The price in dollars is calculated correctly, but the price in euros should be 100. For some reason a 20% tax is added to the euro price. Although in the settings it is set to exclude tax

January 23, 2024 at 3:24 am #15214006

Prosenjit Barman
Supporter

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hello,

Thank you for the update. It's great to hear that you've successfully displayed both the base price and the converted price as intended.

Now, to better assist you with the issue that you're having, I need to understand how the base price alongside the converted price is being displayed on your website. In WooCommerce Multilingual, there isn't a default feature to show the base price with the converted price in this manner as you know. It leads me to believe that there might be custom code involved in your setup.

Could you please provide some insight into how this functionality was implemented? If custom coding was used to achieve this display, I'm sorry to inform you that providing support for custom-coded solutions or resolving issues arising from them is beyond the scope of our support. In such cases, it might be best to consult with the developer who implemented the custom code.

However, if this was set up using settings within WooCommerce or WooCommerce Multilingual, I would gladly assist. Please let me know where and how you've adjusted the settings related to currency display and conversion. This information will enable me to better understand your setup and guide you toward a potential solution.

Looking forward to your response.

Best regards,
Prosenjit

January 23, 2024 at 9:32 am #15215164

pavelZ-3

Good afternoon. I am getting the price in Euro (which is the base currency) using the hook from the documentation you provided:

$eur_price = apply_filters( 'wcml_product_price_by_currency', $_product->get_id(), 'EUR' ) ;

If Euro currency is selected on the site, the price is displayed correctly (100 eur), but if you change the currency, the price will add tax and get 120eur.

At the same time the price in the selected currency is calculated correctly from 100eur and does not add tax.

To display the price I use this code:
$current_currency = get_woocommerce_currency();

if($current_currency == "EUR"){
echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key );
}
elseif($current_currency == "USD"){
echo wc_price( $eur_price, array('currency' => 'EUR')) . ' (' . apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ) . ')';
}
else{
echo wc_price( $eur_price, array('currency' => 'EUR')) . ' (' . apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ) . ')';
}

price_usd.PNG
price_eur.PNG
January 24, 2024 at 5:34 am #15219478

Prosenjit Barman
Supporter

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hi There,
Thank you for the update.

The issue you're having in other currencies could be happening due to how the tax is being applied or displayed when the currency is switched from Euro to another currency on your site. Please nsure that your tax settings in WooCommerce are correctly configured. WooCommerce allows you to display prices either including or excluding tax, and this setting might be impacting how prices are displayed in different currencies.

Please also recheck the currency conversion logic. In the elseif and else blocks, you're using wc_price( $eur_price, array('currency' => 'EUR')). This might be causing an issue as it converts the Euro price to Euro again. Instead, it should probably convert the Euro price to the current currency.

If these suggestions do not resolve the issue, it may be due to specific aspects of your custom code. As providing support for custom coding is beyond the scope of our support, we recommend consulting with a professional developer who can delve deeper into the custom code aspects of your site.

For expert assistance, you can consider hiring a developer, who specializes in customizing WPML and its add-ons from here: https://wpml.org/contractors/. A professional developer will be able to review your code in detail and provide a tailored solution to address the issue you are facing.

If you have any more questions or need further assistance within our support scope, please feel free to reach out.

Best regards,
Prosenjit

The topic ‘[Closed] WCML. How to get the price in base currency on a page with another currency?’ is closed to new replies.