Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
maderlock opened this issue Nov 3, 2017 · 5 comments

Comments

@maderlock
Copy link

maderlock commented Nov 3, 2017

Setup

  • Magento 2.1.9
  • Matrix rates 20.1.3
  • Upload matrix rates with a single shipping method but multiple lines depending on country. See attached shipping_matrix_example.txt
  • Set default country to same as in file (in this case UAE)

Steps to reproduce

  • Create customer with address in default country and specific city (e.g. Dubai in this case)
  • Logout
  • Add item to basket and visit cart - shipping will be estimated based on default location country, state and zip
  • Continue to checkout
  • Enter email address of customer and password when prompted
  • Press continue button

Expected

  • Continue to payment step

Actual

  • Error displayed: "Carrier with such method not found: matrixrate_183, matrixrate"

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
Copy link
Author

maderlock commented Nov 3, 2017

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
Copy link
Author

maderlock commented Nov 3, 2017

Unless you believe that this is specifically to do with cities being ignored? I've just spotted magento/magento2#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
Copy link
Contributor

wsagen commented Nov 8, 2017

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
Copy link
Author

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
Copy link
Contributor

wsagen commented Nov 8, 2017

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

@wsagen wsagen closed this as completed Nov 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants