magento 2.3 如何在自定义运输方式中获取地址表格

问题描述

我想以自定义运输方式在结帐表格中获取地址 enter image description here

public function collectRates(RateRequest $request)
    {
      if (!$this->getConfigFlag('active')) {
        return false;
      }
      $result = $this->rateResultFactory->create();
      $method = $this->rateMethodFactory->create();
      $method->setCarrier('shipping');
      $method->setCarrierTitle($this->getConfigData('title'));
      $method->setMethod('shipping');
      $method->setMethodTitle($this->getConfigData('name'));
      $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/mymodule_shipping.log');
      $logger = new \Zend\Log\Logger();
      $logger->addWriter($writer);
      $logger->debug('infomation request data ->'.json_encode($request->getData()));
      
      $amount = 500;
      $shippingPrice = $this->getFinalPriceWithHandlingFee($amount);
      $method->setPrice($shippingPrice);
      $method->setCost($amount);
      $result->append($method);
      return $result;
    }

json_encode($request->getData());

{"all_items":[{},{}],"dest_country_id":"TH","dest_region_id":null,"dest_region_code":"Krung Thep Maha Nakhon","dest_street":"32,Charoen Rat Road\n\u0e17\u0e23\u0e32\u0e22\u0e01\u0e2d\u0e07\u0e14\u0e34\u0e19\u0e43\u0e15\u0e49","dest_city":"\u0e40\u0e02\u0e15\u0e04\u0e25\u0e2d\u0e07\u0e2a\u0e32\u0e21\u0e27\u0e32","dest_postcode":"10600","package_value":2890,"package_value_with_discount":2890,"package_weight":1,"package_qty":1,"package_physical_value":2890,"free_method_weight":1,"store_id":1,"website_id":"1","free_shipping":false,"base_currency":{},"package_currency":{},"limit_carrier":null,"base_subtotal_incl_tax":2890,"country_id":"TH","region_id":null,}

谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)