<?php
/**
* Bypass the location detected by the Tax Display by Country plugin.
*
* @param string country_code
* @param string ip_address
* @return string
* @author Aelia <[email protected]>
*/
add_filter('wc_aelia_tdbc_customer_location', function($location) {
// Replace "producing_feed" with your own logic to determine when you are
// producing a feed.
//
// A further improvement, to handle country-specific feeds, would be to pass
// the country via the URL. For example, you could call http://example.org/gpf/feed?feed_country=US.
// In the filter, you could check if $_GET['feed_country'] is set and, if it is,
// take that country code directly. This gives maximum flexibility, and it's
// particularly useful on sites that must produce multiple different feeds,
// e.g. one for UK, one for the US, one for Australia, and so on.
if(producing_feed()) {
// Set the country to shop's base location
$location = array(
// Set the country to shop's base location
'country' => 'AU',
'state' => '',
);
}
return $location;
}, 10, 1);
/**
* Bypass Country geolocation.
*
* @param string country_code
* @param string ip_address
* @return string
* @author Aelia <[email protected]>
*/
add_filter('wc_aelia_ip2location_before_get_country_code', function($country_code, $ip_address) {
// Replace "producing_feed" with your own logic to determine when you are
// producing a feed.
//
// A further improvement, to handle country-specific feeds, would be to pass
// the country via the URL. For example, you could call http://example.org/gpf/feed?feed_country=US.
// In the filter, you could check if $_GET['feed_country'] is set and, if it is,
// take that country code directly. This gives maximum flexibility, and it's
// particularly useful on sites that must produce multiple different feeds,
// e.g. one for UK, one for the US, one for Australia, and so on.
if(producing_feed()) {
// Set the country to shop's base location
$country_code = 'AU';
}
return $country_code;
}, 10, 2);
/**
* Bypass State geolocation.
*
* @param string state_code
* @param string ip_address
* @return string
* @author Aelia <[email protected]>
*/
add_filter('wc_aelia_ip2location_before_get_state_code', function($state_code, $ip_address) {
// Replace "producing_feed" with your own logic to determine when you are
// producing a feed
if(producing_feed()) {
$state_code = '';
}
return $state_code;
}, 10, 2);
Comments