通过woocommerce地理位置获取用户区域/城镇

时间:2020-05-09 10:08:36

标签: php wordpress woocommerce geolocation

我尝试过使用woocommerce geolocate,并且只返回如下所示的国家/地区

function custom_use_geolocated_user_country(){
// Geolocation must be enabled @ Woo Settings
$location = WC_Geolocation::geolocate_ip();
echo $location;
}

仅返回如下所示的国家/地区

enter image description here

我尝试使用WC_Geolocation类的其他方法,例如geolocate_ip(),以获得与外部API服务(例如https://ipinfo.io)一起使用的客户IP地址,这似乎很接近我的需求。 / p>

enter image description here

从上图中,我需要获取FCT中的确切区域,例如Gwarimpa,Kuje,Garki等。

欢迎任何实现或获得客户邮政编码的想法。

0 个答案:

没有答案
相关问题