微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决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 举报,一经查实,本站将立刻删除。