webshopapps / module-matrixrate

WebShopApps MatrixRates for Magento2
Open Software License 3.0
120 stars 64 forks source link

Carrier with such method not found when checking out with existing customer #36

Closed maderlock closed 6 years ago

maderlock commented 6 years ago

Setup

Steps to reproduce

Expected

Actual

This may sound like an edge case, but for a client that has a lot of existing customers and more than one rule row for a given country, this is going to be a common occurrence (as I have practically found).

What appears to be going on here is that the previously estimated method is submitted with the stored address in the checkout, and Magento 2 attempts to set this. However, by this point the new address has meant that a different rule is active (because with the same name only the cheapest is active), so Magento believes that the shipping method is not available.

To get around this issue I commented out the following lines in /vendor/magento/module-checkout/Model/ShippingInformationManagement.php:

     if (!$shippingAddress->getShippingRateByCode($shippingAddress->getShippingMethod())) {
        throw new NoSuchEntityException(
            __('Carrier with such method not found: %1, %2', $carrierCode, $methodCode)
        );
    }

After doing this I found that could get to the payment step using the same steps. And checkout with some payment methods. However, offline payment methods like Cash on Delivery give the following error when attempting to submit: "Please specify a shipping method"

So this suggests that the problem has been moved rather than resolved.

maderlock commented 6 years ago

I have attempted to recreate a similar issue with built in shipping methods free shipping and flat rate with different countries, but in this case it recalculates after being logged in. The same for table rates.

So it would appear to be specific to this module.

maderlock commented 6 years ago

Unless you believe that this is specifically to do with cities being ignored? I've just spotted https://github.com/magento/magento2/issues/3789

If that's the case, would you recommend trying https://github.com/shopgo-magento2/checkout-city to get around this until they fix the issue? UPDATE: This extension does not install for 2.1.x. Do you have any alternative?

wsagen commented 6 years ago

Hi @maderlock - thanks for raising this. I am presuming that your shipping rates are dependent on location and are providing a default rate. The rate differs with the address retrieved from login.

Can you retest this scenario with the built in tablerate carrier. This is more closely related to Matrixrate and would therefore alter the shipping options dependent on address, where as flat rate and free shipping both don't alter shipping rates based on the destination.

maderlock commented 6 years ago

They are dependent on location, and I was only getting the issue where the rate depended specifically on city. Built-in rates were fine including table rates, but then that does not support cities. The checkout-blocking problem went away if I used flat rate to do the basic rate for a country and matrix rates to do the city and amount specific rate within the country (though this did of course show two options).

99% sure this is related to magento/magento2#3789 - the problem completely went away by overriding Magento\Quote\Model\ShippingMethodManagement::estimateByAddressId() with http://pastebin.com/3GcesL2H

The issue is supposed to be fixed in 2.1.10, though I have not tested as it only came out today.

wsagen commented 6 years ago

It will be related and as such, an issue with core Magento. I am closing this issue.