woocommerce_get_geolocation
Get geolocation filter.
Usage
add_filter( 'woocommerce_get_geolocation', 'wp_kama_woocommerce_get_geolocation_filter', 10, 2 );
/**
* Function for `woocommerce_get_geolocation` filter-hook.
*
* @param array $geolocation Geolocation data, including country, state, city, and postcode.
* @param string $ip_address IP Address.
*
* @return array
*/
function wp_kama_woocommerce_get_geolocation_filter( $geolocation, $ip_address ){
// filter...
return $geolocation;
}
- $geolocation(array)
- Geolocation data, including country, state, city, and postcode.
- $ip_address(string)
- IP Address.
Changelog
| Since 3.9.0 | Introduced. |
Where the hook is called
woocommerce_get_geolocation
woocommerce/includes/class-wc-geolocation.php 184-193
$geolocation = apply_filters( 'woocommerce_get_geolocation', array( 'country' => $country_code ? $country_code : '', 'state' => '', 'city' => '', 'postcode' => '', ), $ip_address );
Where the hook is used in WooCommerce
woocommerce/includes/integrations/maxmind-geolocation/class-wc-integration-maxmind-geolocation.php 83
add_filter( 'woocommerce_get_geolocation', array( $this, 'get_geolocation' ), 10, 2 );