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.

Tagged: 

This topic contains 11 replies, has 2 voices.

Last updated by Bigul 1 year, 7 months ago.

Assisted by: Bigul.

Author Posts
November 15, 2023 at 1:38 pm #14809193

fionaM-12

Having issues with Currency switcher. It does not change currency based on country / IP of the user. Also, the currency selector has disappeared

November 15, 2023 at 3:37 pm #14811083

fionaM-12

Still not working.

November 15, 2023 at 4:25 pm #14811699

Bigul
WPML Supporter since 01/2013

Languages: English (English )

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

Hello,

Thank you for the updates. Please fill in the private details fields after a full site backup{mandatory}. I would like to access the admin area of your site for further checking. Refer to the following links for more details about our private information sharing policies.

https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

hidden link

Please allow me to make a duplicator copy of your site using the Duplicator plugin(https://wordpress.org/plugins/duplicator/) for debugging the issue on my local server.

--
Thanks!

Bigul

November 16, 2023 at 4:52 am #14821713

Bigul
WPML Supporter since 01/2013

Languages: English (English )

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

Hello,

Please check the attached image. Now the staging site is asking for the Authorization credentials.

So I am enabling the private option for the next reply. Please share the credentials to access it.

--
Thanks!

Bigul

2023-11-16_10-03-25.png
November 16, 2023 at 6:22 am #14822097

fionaM-12

I have removed the security popup. please check.

November 16, 2023 at 8:55 am #14823147

Bigul
WPML Supporter since 01/2013

Languages: English (English )

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

Hello,

Thank you for the updates. I can access the site now. Can I switch the theme to the default 2023 for debugging?

--
Thanks!

Bigul

November 16, 2023 at 11:09 am #14824749

fionaM-12

Hi Support,
I need to manually switch the currency switcher as per IP Location using Javascript in WordPress, can you please tell me what hook or code i can do?

Thanks
Mahendra

November 16, 2023 at 11:37 am #14825083

Bigul
WPML Supporter since 01/2013

Languages: English (English )

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

Hi Mahendra,

Thank you for the updates. You can use the following hooks for the customizations.

https://wpml.org/wcml-hook/wcml_client_currency/

https://wpml.org/wcml-hook/wcml_geolocation_get_user_country/

Please visit the following URL to get more details about WooCommerce Multilingual hooks.

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

--
Thanks!

Bigul

November 16, 2023 at 12:34 pm #14826497

fionaM-12

Hi Support,

I am using the below code to switch the currency, but i have no idea what class or ID i can use for swiche by javascript.
my code is below, please correct this. and i have attached the website switcher screenshot for class. hidden link

document.addEventListener('userCountrySet', function(e) {
var userCountry = e.detail;

// Mapping of countries to currencies
var countryCurrencyMap = {
"USA": "USD",
"UK": "GBP",
"EU": "EUR",
"IN": "GBP"
// Add more mappings as needed
};

// Function to set the default currency in WPML
function setDefaultCurrency() {
var currency = countryCurrencyMap[userCountry] || "USD"; // Default to USD if country not found

// Find WPML currency switcher element and set the value
var currencySwitcher = document.querySelector('.wcml_currency_switcher'); // Replace with the correct ID or class

if (currencySwitcher) {
currencySwitcher.value = currency; // Set the currency
// Trigger any change events if necessary
var event = new Event('change');
currencySwitcher.dispatchEvent(event);
}
}

// Run the function
setDefaultCurrency();

});

Screenshot 2023-11-16 180322.png
November 16, 2023 at 3:10 pm #14828289

Bigul
WPML Supporter since 01/2013

Languages: English (English )

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

Hello,

Thank you for the feedback. I have consulted about this with our team for the expert opinion. Sorry, we have limitations to supporting customized themes/plugins or codes as a part of our support policies. But maybe you can find a workaround using wcml_load_currency function of the following JS file.

hidden link

Also, one request. Please downgrade to 5.2.1 version of WooCommerce Multilingual on your staging site after a site backup and make sure the issue exists or not.

--
Thanks!

Bigul

November 16, 2023 at 3:46 pm #14828473

fionaM-12

Hi Support,
Don't worry i have fixed the issue. Thanks For support.

November 16, 2023 at 4:04 pm #14828723

Bigul
WPML Supporter since 01/2013

Languages: English (English )

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

Hello,

Thank you for the feedback. Happy to know you are getting the expected results now. Please feel free to ping us if you need any further assistance with WPML.

--
Thanks!

Bigul