Search code examples
phpmagentomagento2

Magento 2 Custom shipping Carrier module


I am sort of new to magento 2, I have to add custom shipping carrier using an API which gives multiple options based on product dimensions.

using http://inchoo.net/magento-2/creating-a-shipping-method-in-magento-2/ I was able to get it in. the only issue is that I am supposed to have multiple methods or options for users to select.

I was able to add multiple methods by doing something like below

 for ($n = 0; $n < count($optionz); $n++) {
        $method = $this->_rateMethodFactory->create(); 
        $method->setMethod($this->_code."_".$n);
        $method->setCarrier($this->_code);
        $method->setCarrierTitle($optionz[$n]['service']);
        $method->setCost($optionz[$n]['fee']);
        $method->setPrice($optionz[$n]['fee']);
        $result->append($method);
    }

but once I select the option from checkout page and click next I get below:

"Carrier with such method not found: %1, %2"

any ideas? thanks in advance :).

Kind Regards Sajid


Solution

  • Then you must be facing selection issue in js, try to append unique id for each. That should solve the issue.