Title: GEOIP_COUNTRY_CODE incorrect
Last modified: June 11, 2020

---

# GEOIP_COUNTRY_CODE incorrect

 *  Resolved [sqz](https://wordpress.org/support/users/sqz/)
 * (@sqz)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/geoip_country_code-incorrect/)
 * 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](https://wordpress.org/support/users/oscargare/)
 * (@oscargare)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/geoip_country_code-incorrect/#post-12972646)
 * 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)](https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/)
    -  This reply was modified 5 years, 11 months ago by [Oscar Gare](https://wordpress.org/support/users/oscargare/).
 *  Plugin Author [Oscar Gare](https://wordpress.org/support/users/oscargare/)
 * (@oscargare)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/geoip_country_code-incorrect/#post-12991327)
 * Hi [@sqz](https://wordpress.org/support/users/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.

 * ![](https://ps.w.org/woocommerce-product-price-based-on-countries/assets/icon-
   256x256.png?rev=1976858)
 * [Price Based on Country for WooCommerce](https://wordpress.org/plugins/woocommerce-product-price-based-on-countries/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-product-price-based-on-countries/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-product-price-based-on-countries/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-product-price-based-on-countries/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-product-price-based-on-countries/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-product-price-based-on-countries/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Oscar Gare](https://wordpress.org/support/users/oscargare/)
 * Last activity: [5 years, 11 months ago](https://wordpress.org/support/topic/geoip_country_code-incorrect/#post-12991327)
 * Status: resolved