PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

GeoIP Specified Currency not respected on load

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hi Pablo,

While doing some testing with people around the world rather than with VPN, we are noticing that in some scenarios where EUR is the designated currency, we are getting a USD storefront that then switches to EUR, when the checkout is reached. Below you can find our GeoIP function in functions.php:

Spoiler

// Force Currency by IP (WOOCS GeoIP settings)
add_action('init', 'change_default_currency');

function change_default_currency() {
$pd = WC_Geolocation::geolocate_ip();
global $WOOCS;
if (isset($pd['country']) AND ! empty($pd['country'])) {
if ('AR' == $pd['country']) {
$WOOCS->set_currency('ARS');
}
elseif ('EU' == $pd['country']) {
$WOOCS->set_currency('EUR');
}
else {
$WOOCS->set_currency('USD');
}
}
}

Here's a UK user video for reference!

Any idea on why this could be happening? The only thing I can think of is that we are using 'EU' (specific to the European Union) to specify EUR and maybe it's conflicting onload vs having a list of countries there (?). Attaching access in the private data.

Thanks man!

Hello

We do not support custom code.

The only thing I can think of is that we are using 'EU'  - YES! You can do a simple test var_dump($pd['country']); - You will see what values this variable returns.

So  use "FR","ES","IT".....

Hi Pablo,

I reinforced this by the suggested approach and it's working, thank you.

Hello

Welcome;)