自定义送货方式 - 结账时的实体店地址?
Custom shipping method - Physical store address in checkout?
我正在使用自定义送货方式,我需要在 collectRates 方法中检索实体店地址以计算运费。
我设法通过这种方式检索了当前商店:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$storeManager = $objectManager->get('Magento\Store\Model\StoreManagerInterface');
$store = $storeManager->getStore();
不过好像不是实体店,只是网店。
有人知道如何检索地址、post 代码和城市吗?
谢谢。
好的,找到了。
可能有人会感兴趣,所以我会post这里的解决方案。
您只需调用getConfig 方法来获取您要检索的字段。
为了检索第一行的街道地址,您必须这样做:
$store->getConfig('general/store_information/street_line1');
您可以在 magento github
上找到不同字段的列表
我正在使用自定义送货方式,我需要在 collectRates 方法中检索实体店地址以计算运费。
我设法通过这种方式检索了当前商店:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$storeManager = $objectManager->get('Magento\Store\Model\StoreManagerInterface');
$store = $storeManager->getStore();
不过好像不是实体店,只是网店。
有人知道如何检索地址、post 代码和城市吗?
谢谢。
好的,找到了。
可能有人会感兴趣,所以我会post这里的解决方案。
您只需调用getConfig 方法来获取您要检索的字段。
为了检索第一行的街道地址,您必须这样做:
$store->getConfig('general/store_information/street_line1');
您可以在 magento github
上找到不同字段的列表