Created
September 30, 2025 16:35
-
-
Save esedic/bfb7c59fd2030383b2d0ab6d6de7cb86 to your computer and use it in GitHub Desktop.
Uses WooCommerce geolocation method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Get current user's location | |
| $geo_data = WC_Geolocation::geolocate_ip(); | |
| $country = $geo_data['country']; | |
| $state = $geo_data['state']; | |
| // Use a specific IP address | |
| $location = WC_Geolocation::geolocate_ip( '8.8.8.8' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment