FOX - WooCommerce Currency Switcher Professional

Using Geolocation causes problems, doesn’t seem to work for me

Attention: from WooCommerce v.3.9 for geolocation functionality maxmind key required in woocommerce settings: wp-admin/admin.php?page=wc-settings&tab=integration&section=maxmind_geolocation


Try to change geo location rules and look them in different browsers, because the same browser will show you only first result. Even better send link to the friends, because if data storage selected as transient (also memcached or redis) you will see the same result in all browsers in your computer (the same IP) – another computer necessary – share link with friends.

Example:

You are in Spain, and want to check GeoLocation, so add JPY for example, save, go to Geo rules and for JPY set Spain 

Open Opera browser for example, I mean any another browser you not used for testing your site else and you will see that JPY is set! Do not do the same test in the same browser already, today exactly….

GeoLocation provided by native woocommerce native API, so it should works perfectly … Any way WOOCS uses woocommerce functionality. Sometimes happens that in the places near border geo ip shows another country, for example in Spain in city Logroño shows that its in France.

Accuration: https://www.maxmind.com/en/geoip2-city-accuracy-comparison

From version 2.1.8/1.1.8 its possible use for testing this shortcode: [woocs_geo_hello] – drop it usual text-widget or any page to see info about state of GeoIp functionality on your site.


Also you can try next –  insert code below in your current wp theme file functions.php:

add_filter("woocs_geobone_ip",function(){
    return true;
});

If you using any cache plugins enable: WooCommerce settings -> General -> Default customer location

If you using rocket cache plugin disable option ‘Enable caching for logged-in WordPress users‘:

For testing GeoIP functionality you can use next service: https://www.locabrowser.com


ATTENTION: If you sure that recommendations above done right – check is woo geo functionality works at all on your site: just insert in usual text widget shortcode [woocs_geo_hello]


Another examples of an issue:

The matter was just solved today. I would like to share with you how it was solved after reaching out to my provider and WC, just in case a client having the same provider comes forward with the same issue.

So my provider is Bluehost. It seems that only recently they started to populate HTTP_X_FOWARDED_FOR with my server’s static IP. Maybe this happened after some update they did, i don’t know. They weren’t really helpful in providing info regarding all this. WooCommerce were the ones who were able to detect the problem after some time and suggested a solution/ work around.
WooCommerce will generally check the following variables for the real IP (starting from the top):

HTTP_X_REAL_IP
HTTP_X_FORWARDED_FOR
REMOTE_ADDR
So WooCommerce is looking up the country for this IP address instead of the IP address that is stored in REMOTE_ADDR.

WooCommerce expects the HTTP_X_FORWARDED_FOR to be in the following format:

Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2
Make sure we always only send through the first IP in the list which should always be the client IP.

WooCommerce suggested a work around which would involve a snippet to be added to functions.php to override it:

if ( isset( $_SERVER['REMOTE_ADDR'] ) && ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
    $_SERVER['HTTP_X_FORWARDED_FOR'] = $_SERVER['REMOTE_ADDR'];
}

After adding the snippet to functions.php all worked well and was finally able to activate currency switcher again 🙂

Note: also, found out hostgator had a similar issue as well https://wordpress.org/support/topic/same-ip-address-for-all-orders/page/2/#post-11362720

Cheers,
Ezz


Cloudflare

Hey there,

I am using this plugin for years and it had worked great until we changed our server. I tried most things suggested on the forum but couldn’t succeeded. When I use the plugin it only shows Euro currency even if it is configured to show Turkish Lira in Turkey. We are using Ubuntu 22.04 on EC2 with Cloudpanel and our DNS records on Cloudflare. Do you have any suggestion for us to reactivate location detection?

Resolved:

Hello Pablo & everyone reading this,

Thank you for your support, unfortunately this was not the cause of my problem. I couldn’t figure it out that day but now I solved it.

Our new server uses Ngnix / Cloudpanel and Varnish Cache system is active. When the Varnish is active, it creates a load balancer like wall in front of server, so when user visit the website, it actually visits Varnish before & IP send to Woocommerce is varnish’s IP. Problem solved when I added” real_ip_header CF-Connecting-IP;” to my Vhost file & then deactivate Varnish Cache. I am still working on how Varnish and currency switcher plugin can work together, if I found a solution I will share it too.

Hope this helps other people who has the same or similar issue.

 

Source: https://pluginus.net/support/topic/problem-with-new-server/


Notes for WP Rocket: FOX doesn’t work while WP Rocket is active