Advertisement
businessdad

Aelia Currency Switcher - Use Cloudways country geolocation

Jun 21st, 2020
1,901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.80 KB | None | 0 0
  1. /**
  2.  * Aelia Currency Switcher - Fetch the geolocation country from Cloudways.
  3.  * The code in this example will take the country from the header set by Cloudways
  4.  * (if present) and skip the internal geolocation logic used by the Aelia plugins, such
  5.  * as Aelia Currency Switcher, Aelia Prices by Country and Aelia Tax Display by Country.
  6.  *
  7.  * For more information about the geolocation feature offered by Cloudways, please
  8.  * refer to their documentation: https://support.cloudways.com/use-geoip-with-your-application/
  9.  *
  10.  * IMPORTANT
  11.  * Plugins like the Aelia Tax Display by Country also handle the county/province/state,
  12.  * which Cloudways doesn't return. In that case, the plugin will still use its internal
  13.  * logic to fetch that information.
  14.  *
  15.  * GPL DISCLAIMER
  16.  * THE USE OF THIS CODE IS AS YOUR OWN RISK.
  17.  * This code is provided free of charge and comes without any warranty, implied or explicit, to the extent permitted
  18.  * by applicable law. Except when otherwise stated in writing the copyright holders and/or other parties provide the
  19.  * program "as is" without warranty of any kind, either expressed or implied, including, but not limited to, the implied
  20.  * warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance
  21.  * of the program is with you. Should the program prove defective, you assume the cost of all necessary servicing, repair
  22.  * or correction.
  23.  *
  24.  * Need a consultation, or assistance to customise this code? Find us on Codeable: https://aelia.co/hire_us
  25.  */
  26.  
  27. add_filter('wc_aelia_ip2location_before_get_country_code', function($country, $ip_address) {
  28.   // Return the country from the header set by Cloudways
  29.   return isset($_SERVER['HTTP_X_FORWARDED_COUNTRY']) ? $_SERVER['HTTP_X_FORWARDED_COUNTRY'] : $country;
  30. }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement