我在Magento 2站點上使用WebShopApps_MatrixRates模塊,并且該模塊配置有一種用于該地區的投放方式,而另外兩種用于該地區某些城市的投放方式。我已經在購物車頁面上設置了“估算稅和運費”表格,以顯示地區和城市字段。偏好:Magento \ Checkout \ Block \ Cart \ LayoutProcessor public function process($jsLayout) { $elements = [ 'city' => [ 'visible' => true, 'formElement' => 'select', 'label' => __('City'), 'options' => $this->bcCitiesOptionsArray, ], 'country_id' => [ 'visible' => false, //Remove the country 'formElement' => 'select', 'label' => __('Country'), 'options' => [], 'value' => null ], 'region_id' => [ 'visible' => true, 'formElement' => 'select', 'label' => __('State/Province'), 'options' => [], 'value' => null ], 'postcode' => [ 'visible' => false, //Remove Postal Code 'formElement' => 'input', 'label' => __('Zip/Postal Code'), 'value' => null ] ]; if (!isset($jsLayout['components']['checkoutProvider']['dictionaries'])) { $jsLayout['components']['checkoutProvider']['dictionaries'] = [ 'country_id' => $this->countryCollection->loadByStore()->toOptionArray(), 'region_id' => $this->regionCollection->addAllowedCountriesFilter()->toOptionArray(), ]; }當我用兩種方法選擇一個城市時,將加載具有正確方法和價格的運輸表格。其中不包含有關城市的信息。那么,如何將城市添加到$ shippingInformation變量中?
1 回答

心有法竹
TA貢獻1866條經驗 獲得超5個贊
我找到了解決方案,這很簡單!
由于文件中的過濾,未將城市添加到地址中
供應商/ magento /模塊結帳/視圖/前端/web/js/model/cart/totals-processor/default.js
方法loadFromServer() Line32:
address: _.pick(address, cartCache.requiredFields)
所以我只是覆蓋文件
供應商/ magento /模塊結帳/視圖/前端/web/js/model/cart/cache.js
我的主題并更改了第78行
從:
requiredFields: ['countryId', 'region', 'regionId', 'postcode'],
至:
requiredFields: ['countryId', 'region', 'regionId', 'city'],
它解決了問題!
- 1 回答
- 0 關注
- 96 瀏覽
添加回答
舉報
0/150
提交
取消