silvershop / geocoding
为SilverShop提供地理编码支持。
2.1.0
2022-08-26 01:18 UTC
Requires
README
为SilverShop添加地理编码支持。根据输入的地址计算地址坐标。
安装
composer reqire silvershop/geocoding
配置
提供默认配置,但您可以定义自己的配置。
在_config.php
$geocoder = new \Geocoder\Geocoder(); $adapter = new \Geocoder\HttpAdapter\CurlHttpAdapter(); $geocoder->registerProvider( new \Geocoder\Provider\ChainProvider(array( new \Geocoder\Provider\HostIpProvider($adapter), new \Geocoder\Provider\GoogleMapsProvider($adapter) )) ); AddressGeocoding::set_geocoder($geocoder);
要本地测试IP,您可以在配置中设置一个'test ip'。
Address: test_ip: 202.160.48.114
将relocateuser=1
添加到URL中,以重新运行地理编码器。
禁用地址坐标地理编码
默认情况下,如果地址尚未计算,则在保存时自动检索地址的纬度和经度。可以通过以下方式禁用此行为
Address: enable_geocoding: false
禁用自动访客IP地理编码
默认情况下,此模块会为每个访客地理编码IP。可以通过以下方式禁用此行为
Page: geocode_visitor_ip: false
警告
依赖于第三方地理编码服务可能会降低您的网站速度,尤其是在外部服务负载较重时。您可能需要考虑设置自己的地理编码服务器实例。
地图回退
如果地址无法进行地理编码,则提供一个回退结账步骤,使用谷歌地图字段指定坐标。
请确保将结账步骤添加到yaml配置中。在账单地址之后添加将最合适。
CheckoutPage: steps: 'membership' : 'CheckoutStep_Membership' 'contactdetails' : 'CheckoutStep_ContactDetails' 'shippingaddress' : 'CheckoutStep_Address' 'billingaddress' : 'CheckoutStep_Address' 'addresslocation' : 'CheckoutStep_AddressLocationFallback' #here 'shippingmethod' : 'CheckoutStep_ShippingMethod' 'paymentmethod' : 'CheckoutStep_PaymentMethod' 'summary' : 'CheckoutStep_Summary'