woocommerce_geolocate_ip filter-hookWC 3.9.0

Filter to allow custom geolocation of the IP address.

Usage

add_filter( 'woocommerce_geolocate_ip', 'wp_kama_woocommerce_geolocate_ip_filter', 10, 4 );

/**
 * Function for `woocommerce_geolocate_ip` filter-hook.
 * 
 * @param string $geolocation  Country code.
 * @param string $ip_address   IP Address.
 * @param bool   $fallback     If true, fallbacks to alternative IP detection (can be slower).
 * @param bool   $api_fallback If true, uses geolocation APIs if the database file doesn't exist (can be slower).
 *
 * @return string
 */
function wp_kama_woocommerce_geolocate_ip_filter( $geolocation, $ip_address, $fallback, $api_fallback ){

	// filter...
	return $geolocation;
}
$geolocation(string)
Country code.
$ip_address(string)
IP Address.
$fallback(true|false)
If true, fallbacks to alternative IP detection (can be slower).
$api_fallback(true|false)
If true, uses geolocation APIs if the database file doesn't exist (can be slower).

Changelog

Since 3.9.0 Introduced.

Where the hook is called

WC_Geolocation::geolocate_ip()
woocommerce_geolocate_ip
woocommerce/includes/class-wc-geolocation.php 159
$country_code = apply_filters( 'woocommerce_geolocate_ip', false, $ip_address, $fallback, $api_fallback );

Where the hook is used in WooCommerce

Usage not found.