Magento – Shipping failure – 404 or 400 on Magento 2

magento2shipping

When a user orders using a valid address any where in Massachusetts or Montana then attempts to proceed past the shipping step of the one page checkout They're hit with the following errors;

Table rates shipping method selected; (Magento native configuration)

error;

POST daad827….js:12695 POST http://livingfresh.com/rest/default/V1/guest-carts/423071982511bf7b3d3fa8a0c1e9d228/shipping-information 404 (Not Found)

Upon navigating to the link above I land on a page that states;
"This XML file does not appear to have any style information associated with it. The document tree is shown below."

<response>
<message>Request does not match any route.</message>
</response>

error comes from file;

http://livingfresh.com/pub/static/_cache/merged/daad827d0070acc6a4deedf6cf1c72ae.js

offending code in file above;

// Do send the request
// This may raise an exception which is actually
// handled in jQuery.ajax (so no try/catch here)
xhr.send( ( options.hasContent && options.data ) || null );

When the user tries to use the express method (Magento native configuration) they get a 400 error from the same code and the same file.

Thanks.

Best Answer

This might happen when third-party/own modules try to add data to quote and do not consider that there must be an additional implementation for guest quotes and/or use the wrong classes.

As far as I was able to figure this out:

Use \Magento\Quote\Model\GuestCart\GuestCartRepository for guests

And \Magento\Quote\Model\QuoteRepository for existing customers