Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client has a shop with multiple currencies using WooCommerce Multilingual & Multicurrency. When a customer in Colombia adds items to the cart and sees prices in COP, then changes the shipping address to Germany, the cart updates to show prices in EUR. However, upon sending the order, the amount sent to the payment service provider is in COP instead of EUR, leading to a significant discrepancy in the charged amount.

Solution:
1. We suggested disabling the "WooCommerce PayU Latam Payment Gateway" to check if the issue persists, indicating a potential conflict between the payment gateway plugin and WCML.
2. We provided documentation explaining that logged-in customers should see currencies based on their billing address, while others should see currencies based on their IP address. Documentation Link
3. We recommended using the

wcml_geolocation_get_user_country

hook to override the geolocation and ensure the correct currency displays at checkout. Here's the code snippet that according to the client solved the issue:

// Always use the shipping address if it's available
add_filter( 'wcml_geolocation_get_user_country', function( $userCountry, $allCountries ) {
$customerSession = WC()->session->get('customer');
return !empty( $customerSession['shipping_country'] ) ? $customerSession['shipping_country'] : $userCountry;
}, 10, 2 );

4. As an alternative, we suggested not using the "location" feature and instead using the "Currency by Site Language" setting.

Please note that the solution provided might be outdated or not applicable to your case. If the issue persists, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you still need assistance, please open a new support ticket at our support forum.

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.

Tagged: 

This topic contains 12 replies, has 3 voices.

Last updated by Andreas W. 1 year, 2 months ago.

Assisted by: Andreas W..

Author Posts
April 4, 2024 at 2:12 pm #15484053

christianF-62

The following scenario:

We have a shop with several currencies. We use the WooCommerce Multilingual & Multicurrency plugin for this purpose. I am in Colombia and when I visit the shop I see the price in COP. Now I add items to the shopping basket. In the shopping basket, I change the country for the invoice/delivery to Germany. The prices in the shopping basket are updated and displayed correctly in EUR.

Now for the problem: The prices are displayed correctly, but when I send the order, the currency EUR and not COP is sent to the payment service provider. For example: 70000 COP (~17 EUR) is displayed in the shopping basket, but I shall pay 70000 EUR.

You could do a test under hidden link and put a product into the shopping cart. Then simply change the country in the shopping basket to Colombia and select PayU or PayPal as the payment service provider.

April 4, 2024 at 5:24 pm #15485149

Laura
WPML Supporter since 05/2018

Languages: English (English ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

Hi,

thanks for contacting us.

Can you please update WPML and the other plugins to the latest version, and see if the issue persists?
I see you're using WordPress 5.6 but WPML 4.6.9 is not compatible with it.

You can update from Plugin > Add new > Commercial tab

April 5, 2024 at 11:13 am #15487635

christianF-62

Hello Laura,

I think you made a mistake. The WordPress version is 6.5 and not 5.6. I updated WPML, String Translation and Media Translation to the latest versions. The issue still occurs.

April 5, 2024 at 6:38 pm #15489482

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

I tried to make an order by using Germany as the shipping address.

If I try PayPal I get this unexpected message:
CURRENCY_NOT_SUPPORTED Currency code is not currently supported. Please refer hidden link for list of supported currency codes.

If I use PayU it does convert the Euros to USD. I can not confirm that to changes to COP. PayU should support EURO.

This could be an issue between the used payment gateway plugin and WCML.

Can you please test if the issues do not occur, if "WooCommerce PayU Latam Payment Gateway" is disabled?

Please run a quick test and see if you can recreate this issue with a simple test product using the same approach on the following test site:

One-Click-Login:
hidden link

Let me know the outcome of your test.

April 8, 2024 at 9:25 am #15493281

christianF-62

Hello Andreas,

PayPal does not support COP. Therefore, you would have to use a Colombian IP and set the country in the checkout to Germany to reproduce the issue. The price will then change to EUR in the checkout. However, it will apparently be sent to PayPal in COP, which is why you will receive the same error message (CURRENCY_NOT_SUPPORTED ...).

> Can you please test if the issues do not occur, if "WooCommerce PayU Latam Payment Gateway" is disabled?

It doesn't matter if it's disabled. The issue still occurs.

I have tried to reproduce the problem in the test environment. But so far I could only test the PayPal plugin and that seems to work. However, the change of currencies in the checkout only works when logged in. If I am not logged in, the country is determined by the IP and cannot be overwritten by the selection in the checkout.

PayU was originally set up by a colleague. I will have to ask him to support me there. As soon as we have carried out the test, I will get back to you.

April 9, 2024 at 12:36 pm #15499272

christianF-62

Hi Andreas,

The issue only seems to occur when you are not logged in. As soon as you log in to WordPress, everything works correctly. We have tested this with PayU and PayPal in our store.

In the test environment, the currency change only works when you are logged in. There is probably a bug, which needs to be fixed.

April 9, 2024 at 1:48 pm #15499519

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

I can only escalate a bug if we can recreate the issue on a new test site.

I would like to offer to have a closer look at the problem and request temporary access (wp-admin and FTP) to the website to investigate this issue further.

You can find the required fields below the comment section when you log in to leave the next reply. The information you provide is private, which means only you and I can see and access it.

IMPORTANT
Please be sure to make a backup copy of the website and database before allowing us access.
If you can't see the wp-admin / FTP fields, your post and website credentials are set as PUBLIC. DO NOT publish the data unless you see the required wp-admin / FTP fields.

I may have to install a plugin called "All In One WP Migration" to make a copy of the website where I can investigate the issue further.

However, I would also be very grateful if you could provide a staging site or copy of the website from your server yourself for this purpose.

If you have any questions about creating such a staging site, you can consult your hosting provider. Just take note that WPML should be registered on this site again.

If you are unable to provide such a copy of the site for testing, please let me know on this ticket.

The private response form looks like this:
hidden link

Next time you reply, click "I still need assistance."

Video:
hidden link

Please note that we are obliged to request this information individually on each ticket. We may not access any access information not specifically submitted on this ticket in the private response form.

Best regards
Andreas

April 10, 2024 at 7:26 am #15502453

christianF-62

Hi Andreas,

I think the bug is reproducible on the test page, which is why you don't need access to our installation.

If you are not logged in, the currency does not change when you change the country in the checkout process. If you are logged into WordPress, then it works.

This also seems to be the problem on our site. If you are logged into WordPress, the currency is transferred correctly to the payment service provider. If you are not logged in, it is displayed correctly (elementor probably takes care of this), but is not changed in the form fields to be transferred.

To reproduce the issue on the test page:

1. open hidden link
2. add the product to the cart
3. open the cart
4. start the checkout
5. add address information and change country

The currency will not change, if you are not logged into WordPress.

Now login via hidden link and try the same steps. The currency will change now.

April 10, 2024 at 3:50 pm #15505716

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

If you use the currency per location setting, then the billing address for non-logged-in users will not be taken into consideration.

It will use the IP of the user and the current location for setting the currency.

See the screenshot with VPN testing from Germany.

Source:
https://wpml.org/documentation/related-projects/woocommerce-multilingual/#multiple-currencies

vpn.png
April 10, 2024 at 4:07 pm #15505744

christianF-62

Hi Andreas,

thank you for the clarification.

What is the reason why it works as a logged in user but not as a guest? That doesn't make sense to me at first glance.

Is there then no possibility to set the currency per IP, but to overwrite it later by changing the country in the checkout?

April 10, 2024 at 4:35 pm #15505909

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

According to our documentation, it is supposed to work this way:

"Once you enable currencies based on client location, logged-in customers will see currencies based on their billing address. For other customers, WooCommerce Multilingual will use their IP address to display the correct currency."

Source: https://wpml.org/documentation/related-projects/woocommerce-multilingual/multi-currency-support-woocommerce/#currencies-per-location

April 11, 2024 at 6:47 am #15507152

christianF-62

Hi Andreas,

That's what I read. But isn't there a workaround? Surely we can't be the only store with this requirement?

April 11, 2024 at 3:03 pm #15509956

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

You are using "Currency per Location" and this is how the feature is supposed to work.

To overwrite the geolocation of the current user you can use this hook:
https://wpml.org/wcml-hook/wcml_geolocation_get_user_country/

Example:

// Always use the shipping address if it's available
add_filter( 'wcml_geolocation_get_user_country', function( $userCountry, $allCountries ) {
    return ! empty( $allCountries['shipping'] ) ? $allCountries['shipping'] : $userCountry;
}, 10, 2 );

Please give this a try and let me know if this works for non-logged-in users.

A easier workaround would be not to use the "location" and use the "Currency by Site Language" as a currency setting instead.

April 15, 2024 at 7:57 am #15517516

christianF-62

Unfortunately, your example did not work. However, I was able to create a working workaround based on it.

````
// Always use the shipping address if it's available
add_filter( 'wcml_geolocation_get_user_country', function( $userCountry, $allCountries ) {
$customerSession = WC()->session->get('customer');
return !empty( $customerSession['shipping_country'] ) ? $customerSession['shipping_country'] : $userCountry;
}, 10, 2 );
```

Thank you very much for your support! 🙂