Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento 2:为什么我的定制配送不可见?_Magento_Magento2_Shipping_Magento 2.0 - Fatal编程技术网

Magento 2:为什么我的定制配送不可见?

Magento 2:为什么我的定制配送不可见?,magento,magento2,shipping,magento-2.0,Magento,Magento2,Shipping,Magento 2.0,我有一个自定义的配送模块,最近我将其与datepicker模块结合使用,现在配送选项在结帐页面上不可见。我修改了config.xml文件,将两个模块中的两种配置结合起来,因此我想知道这是否是导致冲突的原因。datepicker工作得很好,但我甚至没有看到控制台中加载自定义的shipping选项 配置: <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:n

我有一个自定义的配送模块,最近我将其与datepicker模块结合使用,现在配送选项在结帐页面上不可见。我修改了
config.xml
文件,将两个模块中的两种配置结合起来,因此我想知道这是否是导致冲突的原因。datepicker工作得很好,但我甚至没有看到控制台中加载自定义的shipping选项

配置:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
   <carriers>
    <icacustomshipping>
        <showmethod>1</showmethod>
        <active>1</active>
        <sallowspecific>0</sallowspecific>
        <price>18</price>
        <model>SR\DeliveryDate\Model\Carrier\Customshipping</model>
        <name>Fixed</name>
        <title>ICA</title>
        <origin_address></origin_address>
        <origin_suburb></origin_suburb>
        <authentication></authentication>
        <id></id>
        <specificerrmsg>Error.</specificerrmsg>
    </icacustomshipping>
  </carriers>
</default>
<default>
   <sr_deliverydate>
        <general>
        <format>yy-mm-dd</format>
        <disabled>-1</disabled>
        <hourMin>8</hourMin>
        <hourMax>22</hourMax>
    </general>
  </sr_deliverydate>
 </default>
</config>

1.
1.
0
18
SR\DeliveryDate\Model\Carrier\Customshipping
固定的
伊卡
错误
年月日
-1
8.
22
运输模式

<?php

namespace SR\DeliveryDate\Model\Carrier;

use Magento\Quote\Model\Quote\Address\RateRequest;
use Magento\Shipping\Model\Rate\Result;

class Customshipping extends \Magento\Shipping\Model\Carrier\AbstractCarrier implements
\Magento\Shipping\Model\Carrier\CarrierInterface
{

    /**
     * @var string
     */
    protected $_code = 'icacustomshipping';

    /**
     * @var bool
     */
    protected $_isFixed = true;

    /**
     * @var \Magento\Shipping\Model\Rate\ResultFactory
     */
    protected $_rateResultFactory;

    /**
     * @var \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory
     */
    protected $_rateMethodFactory;

    /**
     * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
     * @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory
     * @param \Psr\Log\LoggerInterface $logger
     * @param \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory
     * @param \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory
     * @param array $data
     */
    public function __construct(
    \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, \Psr\Log\LoggerInterface $logger, \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory, \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory, array $data = []
    )
    {
        $this->_rateResultFactory = $rateResultFactory;
        $this->_rateMethodFactory = $rateMethodFactory;
        parent::__construct($scopeConfig, $rateErrorFactory, $logger, $data);
    }

    /**
     * @param RateRequest $request
     * @return Result|bool
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
     * @SuppressWarnings(PHPMD.NPathComplexity)
     */
    public function collectRates(RateRequest $request)
    {
         if (!$this->getConfigFlag('active')) {
            return false;
        }

        /** @var \Magento\Shipping\Model\Rate\Result $result */
        $result = $this->_rateResultFactory->create();

        /** @var \Magento\Quote\Model\Quote\Address\RateResult\Method $method */
        $method = $this->_rateMethodFactory->create();

        $method->setCarrier('example');
        $method->setCarrierTitle('TEST');

        $method->setMethod('example');
        $method->setMethodTitle('TEST');

        /*you can fetch shipping price from different sources over some APIs, we used price from config.xml - xml node price*/
        $amount = 18;

        $method->setPrice($amount);
        $method->setCost($amount);

        $result->append($method);

        return $result;

    }

    /**
     * @return array
     */
    public function getAllowedMethods()
    {
        return [$this->getCarrierCode() => __($this->getConfigData('name'))];
    }

}

因此,这个问题只是一个简单的语法错误。我有
$method->setCarrier('example'),而我需要将承运人设置为我的装运代码
受保护的$\u代码='icacustomshipping'