CleanCheckout
CleanCheckout copied to clipboard
Cannot read property 'method_code' of null
Hi, We're getting an error when we switch between countries at the Shipping section of the checkout. An example would be switching from United Kingdom to any other country and back again. The first time it works fine but switching back we get this console error. Because of this error the loader does not disappear and we cannot use the rest of the checkout.
Console Error:
select-shipping-method-mixin.js:45 Uncaught TypeError: Cannot read property 'method_code' of null at select-shipping-method-mixin.js:45 at Object.resolveShippingRates (checkout-data-resolver.js:173) at Object.setShippingRates (shipping-service.js:25) at Object.
(new-address.js:59) at fire (jquery.js:3232) at Object.fireWith [as resolveWith] (jquery.js:3362) at done (jquery.js:9840) at XMLHttpRequest.callback (jquery.js:10311)
I think i've fixed it but can you confirm is this is correct?
Within:
vendor/rubic/magento2-module-clean-checkout/src/view/frontend/web/js/mixin/select-shipping-method-mixin.js
Before:
var payload = {...}
Add:
if (shippingMethod === null) { return; }
This also fixed it for me, thanks @pauldonnelly