• Resolved sqz

    (@sqz)


    Hi,
    I’ve tried everything to make the geolocation work, without results.
    In the beginning GEOIP_COUNTRY_CODE only showed SE, which is where the servers is located. I’ve talked to the host that couldn’t solve the issue.
    So I installed and configured Cloudflare. Now it is changing the GEOIP_COUNTRY_CODE, but still it doesn’t always match.
    I’ve also installed a different Currency plugin that’s using it’s own maxmind lookup. This plugin is always showing correct currency.
    Since I installed cloudflare HTTP_CF_IPCOUNTRY is also showing correct information, but it’s not matching GEOIP_COUNTRY_CODE.

    Debug:
    Default customer location: geolocation_ajax
    MaxMind GeoIP database:
    MaxMind license:
    MM_COUNTRY_CODE:
    GEOIP_COUNTRY_CODE: GB
    HTTP_CF_IPCOUNTRY: DE
    HTTP_X_COUNTRY_CODE:
    HTTP_X_REAL_IP:
    HTTP_X_FORWARDED_FOR: 167.172.161.11
    REMOTE_ADDR: 167.172.161.11
    Real external IP: 167.172.161.11
    Const WCPBC_USE_REMOTE_ADDR: –
    Geolocation Test:

    Any idea how to solve the issue?

    Kind regards,

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Oscar Gare

    (@oscargare)

    Hi,

    Try the following snippet:

    add_filter( 'woocommerce_geolocate_ip', 'sqz_geolocate_cf_ipcountry' );
    function sqz_geolocate_cf_ipcountry( $country ) {
        return  $_SERVER[ 'HTTP_CF_IPCOUNTRY' ];
    }

    This forces to WooCommerce to use the HTTP_CF_IPCOUNTRY.

    How to Easily Add Custom Code in WordPress (without Breaking Your Site)

    • This reply was modified 5 years, 11 months ago by Oscar Gare.
    Plugin Author Oscar Gare

    (@oscargare)

    Hi @sqz ,

    It’s been a few days since we replied last. We just wanted to make sure that your issue was resolved or you had any other queries. I would like to inform you that I will mark this thread as resolved in a few days if we do not get a reply back from you within a few days.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘GEOIP_COUNTRY_CODE incorrect’ is closed to new replies.