CleanCheckout icon indicating copy to clipboard operation
CleanCheckout copied to clipboard

Cannot read property 'method_code' of null

Open pauldonnelly opened this issue 5 years ago • 2 comments

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)

pauldonnelly avatar Jan 16 '19 10:01 pauldonnelly

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; }

pauldonnelly avatar Jan 16 '19 10:01 pauldonnelly

This also fixed it for me, thanks @pauldonnelly

razza12 avatar Jul 10 '19 01:07 razza12