How to Create the shipping method through API response

/** @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($this->_code[$i]);
        $method->setCarrierTitle($this->getConfigData('title'));


        $method->setMethod($this->_code[$i]);
        $method->setMethodTitle($this->getConfigData('name'));

        $shippingCost = (float)$this->getConfigData('shipping_cost');

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

        $result->append($method);

}

Leave a comment

Your email address will not be published. Required fields are marked *