在 WooCommerce 独立站上,当用户在结算页面上填写结算信息时,WooCommerce 是没有提供自动定位功能的。但是可以使用第三方的 MaxMind 服务与 WooCommerce 集成,达到自动定位用户位置并生成用户地址的目的,这么做的前提是将版本升级到 3.9+。
首先,依次进入 WooCommerce > Settings > General,在“Default customer address”下选择“Geolocate” or “Geolocate (with page caching support)”。
WooCommerce Settings
WooCommerce Settings
然后,到 MaxMind 上申请一个秘钥,这个步骤很简单,按照网站提示一步一步填写信息就好。申请好密钥之后,在 WooCommerce > Settings > Integration > MaxMind Geolocation 下粘贴秘钥。
Integration
Integration
保存相关设置,清空网站缓存即可。