Magento – Magento 2: Carrier with such method not found

checkoutmagento2shipping

When I'm on Checkout Page. Sometimes I'm facing the below error.

Carrier with such method not found: null, null

I have selected by Shipping Address, Not selected any Shipping Method & Clicked on "Next"

I'm using DHL Shipping Method. I have to override the DHL Shipping Method Model as per my requirement.

Magento 2: How to change Weight field for DHL Shipping Method [SOLVED]

Not sure if anyone comes across this issue.

Best Answer

The above error is triggered when the specified shipping method is not available or is invalid.

As we can see at vendor/magento/module-checkout/Model/ShippingInformationManagement.php:209 if getShippingRateByCode returns false, it throws this exception.

Inside this method we can see that it's not very complex to understand...

    public function getShippingRateByCode($code)
    {
        foreach ($this->getShippingRatesCollection() as $rate) {
            if ($rate->getCode() == $code) {
                return $rate;
            }
        }

        return false;
    }

I can think of 3 possible reasons for that:

  1. You have a saved quote using a shipping method that was disabled
  2. When you changed the shipping method, you forgot to add the constant CODE or changed it value
  3. You've changed the config.xml of the module and forgot to add <model> whitin the default node. I did that once for payment method and got similar error.

I hope any of these suggestions help.