WooCommerce: How to Test Geolocation?

Great question, isn’t it?

How do you make sure your shipping, taxes and currency settings are working properly when they depend on geolocation and you can only test from a single world location?

WooCommerce uses a free geolocation service called MaxMind. By default this is active via the settings but can be disabled. The set of functions (or class) that WooCommerce uses is in the /includes folder, and it’s called Class WC_Geolocation.

Why WooCommerce Geolocation

If you have enabled “geolocation” in your WooCommerce settings (see image), shipping, taxes, currencies and conditional content will be chosen based on the user IP address.

WooCommerce snippets like this can print content on screen based on IP address. Also, plugins such as the currency switcher can automatically geolocate the user in order to function.

Geolocation Testing Tools

A couple of Google searches, and the answer is right there! There are at least 3 decent website services (freemium model) that allow you to test your website from different locations. As a result, you get a screenshot from each location.

These tools are:

Happy testing 🙂

 

Related content

  • WooCommerce: Detecting Current User Country (Geolocation)
    You may need to add some “personalization” to your WooCommerce website homepage. For example, you could print a custom greeting based on the user’s IP address. For that, you can use PHP and WooCommerce inbuilt MaxMind Geolocation integration (when enabled from the General Settings Tab, of course). Detecting the current user country could be very […]
  • WooCommerce: Hide Products Based on IP Address / Geolocation
    There are many plugins that would allow you to do this in bulk or that would give you advanced features… but what if you just need to hide one product ID for users who are visiting your WooCommerce website from a specific country code? This is also called “geolocation” – remember this won’t work unless […]
  • WooCommerce: How to Set Different Prices Based on User Role?
    B2C WooCommerce stores can also have a B2B section. Wholesalers can offer different prices based on different criteria. Subscription stores can offer lower prices to current members. Either way, setting different WooCommerce prices for different users (“based on user role”) is not that difficult. All you need is a plugin (or a stack of plugins, […]
  • free woocommerce pluginsWooCommerce: 85 Free Plugins for Every Challenge
    WooCommerce is one of the most popular WordPress plugin for adding eCommerce or cart functionality to a WordPress website. According to recent research by aheadWorks, WooCommerce now accounts for 26.5% of the total eCommerce market share. And recent acquisition by Automattic indicates that it has a great future ahead. WooCommerce is well known for its […]
  • WooCommerce: How to Enable Multi-Currency?
    If you got here it’s because you’re looking to increase your sales conversion rate by enabling “Multi-Currency” in your WooCommerce website. The concept behind the currency switcher is simple: if I’m based in Europe I’d love paying in Euros, while if I were based in US I wouldn’t fancy the same treatment and I’d prefer […]

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

12 thoughts on “WooCommerce: How to Test Geolocation?

  1. Hi Rodolfo,
    thanks for your article.
    Since I activated Geolocation, “?v=hash” is added after the URL followed by about ten numbers.
    Is it possible to return a clean URL, without these codes?
    Thank you

    1. You can enable geolocation without page caching, that should remove the URL paraneter

  2. I installed everything correctly and installed tools to run the WC_Integration_MaxMind_Geolocation->update_database() cron job but nothing is being populated into the checkout fields. Does it need time to run for the first update?

    1. This would only populate the Country for logged out customers. The country doesn’t work at all?

  3. Worth noting that due to changes at MaxMind you now have to setup integration rather than just let it do its thing. Thanks for the resources!

    1. Yes, good point, thank you!

  4. Since it is an IP-based system I prefer to use a VPS-service to visit the site from another location. This works very reliably – especially when using a private window for every test to prevent cached information and sessions.

    1. Thanks for that Olof!

  5. Hi Rodolfo,

    So if i turn on this geolocation thing in WP, will it auto change the currency for my visitors? or i need the aelia plugin like you mention in another post?

    how do i use your script to modify to redirect visitors based on their locations?

    thanks

    1. No, default Geolocation is to load shipping rates / checkout fields. For currency you need Aelia and for languages you need Polylang/WPML. Both plugins have autoredirect options. Hope this helps

  6. We appreciate the quick article Rodolfo. We are in process of migrating from Shopify to Woocommerce and this is one of our key features we rely on to display the right content for our customers. It’s great to see the website being tested simultaneously around the world.

    Thanks,
    Steve

    1. Excellent, and good luck with the transfer Steve 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *