Cloudways × Aelia Geo IP Location
If you run a professional WooCommerce store based on WordPress, you usually can’t avoid products from Aelia. Especially popular is the Currency Switcher and Tax Display by Country to comply with legal requirements as well as to improve the user experience. For many products, Aelia uses automatic location of the current user – based on the IP address.
However, new and innovative caching technologies, especially NGINX and Varnish Cache, make it difficult to dynamically locate the current user, as WordPress plugins cannot set preferences at the NGINX configuration level. So the location may work, but the cached content is output with the cached and presumably wrong location.
Providers such as Cloudways have recognized this fact and offer their own implementations for locating users. These are usually provided as headers and can be passed to the Aelia framework through a small implementation. This plugin takes care of this implementation.
How To Get Updates
Please note that this plugin does not live in the official WordPress repository, because personally the effort is too much for me and I can’t do it in my spare time. For updates on the plugin it’s best to check this website regularly.
Functions and Necessity
The Aelia framework expects two-digit country codes to continue working with. Cloudways, on the other hand, outputs country names as written out text according to the ISO 3166 standard. This plugin translates the country coming from Cloudways into two-character country codes. A specific CSV file for ISO 3166 is used for this purpose. This may be even faster than the default geolocation mechanism!
Blazing Fast
The plugin is built with performance in mind. It’s very small and performant. At the same time, it’s easy to update country codes – even by yourself. Have a look at the FAQ for more information.
NGINX & Varnish Compatible
NGINX and Varnish are great caching approaches. This plugin supports them and makes Aelia products compatible with Cloudway’s implementation of geolocation feature.
Suitable for all Aelia products
This plugin works with all Aelia products that use geolocation feature including the famous Currency Switcher for WooCommerce, Tax Display by Country for WooCommerce and Prices by Country for WooCommerce.
Built for Cloudways
Cloudways is a great hosting provider with outstanding performance and options. They do also offer a geolocation feature which is taken into account for this plugin.
How-To: Installation & Configuration
The installation and configuration process consists of three steps. Please follow them accordingly.
Activate Geo IP on Cloudways
Log in to Cloudways and navigate to your application where you want to install the plugin. In the application settings, activate the “Geo IP” feature. After a few seconds, the configuration is complete and Cloudways provides information about the location of each visitor of the application (website) that uses this plugin.
Install & Activate Plugin
In the second step, navigate to your WordPress installation and install this plugin. Don’t forget to activate it as well, so that the geolocation information from Cloudways can be passed to the Aelia framework – translated by this plugin. Also make sure to have Aelia products installed.
Clear Cache
Now empty the cache of your website. This works differently depending on the caching plugin. Test the functionality with different countries, e.g. through a VPN.
Changelog / Development Roadmap
Releases
2023-03-05 – V1.0
First public release of the plugin.
Development Plan
- Establish compatibility with other hosting providers
- Connection of the Google API as fallback layer
- Admin interface (GUI) for WordPress backend
Questions & Answers
How can you use geolocation feature of Cloudways for Aelia products?
There are three easy steps: First, activate the Geo IP feature for the individual application on Cloudways. Second, install the WordPress Plugin. Third, clear cache and review carefully.
What about other hosting providers?
I believe that Cloudways is a great choice for WordPress and WooCommerce. This plugin does only support Cloudways. You may use this plugin to create your own version for another hosting provider though. Additionally, the support of Aelia is outstanding.
Does geolocation work with NGINX?
Yes, it does, but it depends on the individual implementation of the hosting company. Cloudways provides a Geo IP feature.
What happens if a country is not detected correctly?
Feel free to get in touch with me. I will add the country to the plugin and submit a new version. The general logic of the plugin is to first search for a match between the country name provided by Cloudways and the ISO 3166 country names. If there’s no match, it will look for a partly match. And if there is no partly match, the plugin will not provide any country code to Aelia and the Aelia logic will be responsible for getting the correct geolocation.
Can I add or change countries manually?
Sure thing. There is a csv file as a part of the plugin which contains the mapping between the country names and the country codes. Simply edit it, save it and there you go.
Are there any limitations?
This plugin is only designed for interaction between Cloudways and Aelia products. The source code can be viewed and customized for additional hosting providers.
Does this plugin slow down my WordPress website?
Well, the code runs every time the website is visited. Therefore, the plugin is kept very small and blazing fast. There isn’t really any effect. It may actually reduce the page loading time as this implementation is very fast and probably faster than the default geolocation implementation. However, if you look at ways how to speed up your website, have a look at CDN with WordPress and Azure.
How can I get updates for the plugin?
This plugin does not live in the official WordPress repository. Therefore, please manually update the plugin by just uploading the new version through the admin interface.
Henning
Hi there, when will the plugin be available to download? 🙂 Thanks for your work!!!
Lennart Wörmer
Hi Henning, the plugin hasn’t made it through the WordPress certification process yet because I haven’t had time to do so. However, I have emailed you the plugin.
Cone-headed Cat
Any chance you can email it to me as well, really want to test it on our environment.
Hemang Pandit
Hi Lennart,
Is there a possibility of making this work with cloud front ? My development team can make the necessary changes if I had your plugin.
Lennart Wörmer
Hi Hemang, sorry for the delay in my response. You got an email. Feel free to chat with me through email for possible changes in the plugin and development ideas. 🙂
Remco
Hi Lennart,
Could you email me the plugin also please?
Remco
Lennart Wörmer
Hi Remco, sorry for the delay in my response. You got an email. 🙂
George
Hello Lennart,
Could you please email me the plugin, thank you!
Lennart Wörmer
Hi George, sorry for the delay in my response. You got an email. 🙂
Maddox
Cant wait for this to come out!
Lennart Wörmer
Hi Maddox, the plugin is now available for public download.
Aaron
Hello Lennart please drop me an email. I have a quick few questions to ask. Thank you
Lennart Wörmer
Hi, you can use the contact form. That would be the easiest way.
Diego - Aelia
Hi Lennart,
Aaron, who also commented today, informed us about this plugin you’ve been developing. As the founder of Aelia, I wanted to thank you for your contribution, and I want to offer my assistance if you have any questions. 👍
I also would like to add a note, that could be worth considering. The Currency Switcher uses a cookie to keep track of the visitor’s currency. The plugin supports custom country/currency mappings (e.g. UK -> EUR, Canada -> USD). Adding such mapping to your plugin could be a good idea. Even though it would have to be maintained manually, it would allow administrators to reflect the plugin settings, and have the currency detection logic produce the same result as the one from the Currency Switcher.
Pyotr
Hello, could you email me the plugin, please!
Lennart Wörmer
Hi Pyotr, the plugin is now available for public download.
Žiga Sancin
You could use the default WooCommerce functionality insted of fetching a csv file without caching.
$countries = WC()->countries->get_countries();
$country_code = array_search( $_SERVER[‘HTTP_X_FORWARDED_COUNTRY’], $countries );