WC_Integration_MaxMind_Geolocation::get_geolocation( array $data, string $ip_address )
Performs a geolocation lookup against the MaxMind database for the given IP address.
Description Description
Parameters Parameters
- $data
-
(Required) Geolocation data.
- $ip_address
-
(Required) The IP address to geolocate.
Return Return
(array) Geolocation including country code, state, city and postcode based on an IP address.
Source Source
File: includes/integrations/maxmind-geolocation/class-wc-integration-maxmind-geolocation.php
public function get_geolocation( $data, $ip_address ) { // WooCommerce look for headers first, and at this moment could be just enough. if ( ! empty( $data['country'] ) ) { return $data; } if ( empty( $ip_address ) ) { return $data; } $country_code = $this->database_service->get_iso_country_code_for_ip( $ip_address ); return array( 'country' => $country_code, 'state' => '', 'city' => '', 'postcode' => '', ); }