Advertisement
businessdad

WooCommerce - WooThemes Ticket #452886

Aug 16th, 2016
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.51 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * Bypass the location detected by the Tax Display by Country plugin.
  5.  *
  6.  * @param string country_code
  7.  * @param string ip_address
  8.  * @return string
  9.  * @author Aelia <support@aelia.co>
  10.  */
  11. add_filter('wc_aelia_tdbc_customer_location', function($location) {
  12.   // Replace "producing_feed" with your own logic to determine when you are
  13.   // producing a feed.
  14.   //
  15.   // A further improvement, to handle country-specific feeds, would be to pass
  16.   // the country via the URL. For example, you could call http://example.org/gpf/feed?feed_country=US.
  17.   // In the filter, you could check if $_GET['feed_country'] is set and, if it is,
  18.   // take that country code directly. This gives maximum flexibility, and it's
  19.   // particularly useful on sites that must produce multiple different feeds,
  20.   // e.g. one for UK, one for the US, one for Australia, and so on.
  21.   if(producing_feed()) {
  22.     // Set the country to shop's base location
  23.     $location = array(
  24.       // Set the country to shop's base location
  25.       'country' => 'AU',
  26.       'state' => '',
  27.     );
  28.   }
  29.   return $location;
  30. }, 10, 1);
  31.  
  32. /**
  33.  * Bypass Country geolocation.
  34.  *
  35.  * @param string country_code
  36.  * @param string ip_address
  37.  * @return string
  38.  * @author Aelia <support@aelia.co>
  39.  */
  40. add_filter('wc_aelia_ip2location_before_get_country_code', function($country_code, $ip_address) {
  41.   // Replace "producing_feed" with your own logic to determine when you are
  42.   // producing a feed.
  43.   //
  44.   // A further improvement, to handle country-specific feeds, would be to pass
  45.   // the country via the URL. For example, you could call http://example.org/gpf/feed?feed_country=US.
  46.   // In the filter, you could check if $_GET['feed_country'] is set and, if it is,
  47.   // take that country code directly. This gives maximum flexibility, and it's
  48.   // particularly useful on sites that must produce multiple different feeds,
  49.   // e.g. one for UK, one for the US, one for Australia, and so on.
  50.   if(producing_feed()) {
  51.     // Set the country to shop's base location
  52.     $country_code = 'AU';
  53.   }
  54.   return $country_code;
  55. }, 10, 2);
  56.  
  57. /**
  58.  * Bypass State geolocation.
  59.  *
  60.  * @param string state_code
  61.  * @param string ip_address
  62.  * @return string
  63.  * @author Aelia <support@aelia.co>
  64.  */
  65. add_filter('wc_aelia_ip2location_before_get_state_code', function($state_code, $ip_address) {
  66.   // Replace "producing_feed" with your own logic to determine when you are
  67.   // producing a feed
  68.   if(producing_feed()) {
  69.     $state_code = '';
  70.   }
  71.   return $state_code;
  72. }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement