magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.5k stars 9.31k forks source link

Mage 2.2.3 Shipping Method not loading #14472

Closed jphat closed 6 years ago

jphat commented 6 years ago

Preconditions

  1. PHP 7.0
  2. MySQL 14.14
  3. Magento 2.2.3

Steps to reproduce

  1. Migrate from 1.9.X
  2. Go through checkout process

Expected result

  1. A list of shipping options

Actual result

  1. Loading wheels keeps spinning
  2. Console shows following error POST http://store.local/rest/default/V1/guest-carts/9a2b6352e8634b961ca6843c5fa45b4a/estimate-shipping-methods 500 (Internal Server Error) Uncaught SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse (<anonymous>) at Object.process (error-processor.js:28) at Object.<anonymous> (new-address.js:82) at fire (jquery.js:3232) at Object.fireWith [as rejectWith] (jquery.js:3362) at done (jquery.js:9842) at XMLHttpRequest.callback (jquery.js:10311)
  3. Apache error logs PHP Fatal error: Uncaught Error: Call to a member function getCheckoutFields() on array in /home/mage/store/vendor/temando/module-shipping-m2/Observer/SaveCheckoutFieldsObserver.php:73\nStack trace:\n#0 /home/mage/store/vendor/magento/framework/Event/Invoker/InvokerDefault.php(72): Temando\\Shipping\\Observer\\SaveCheckoutFieldsObserver->execute(Object(Magento\\Framework\\Event\\Observer))\n#1 /home/mage/store/vendor/magento/framework/Event/Invoker/InvokerDefault.php(60): Magento\\Framework\\Event\\Invoker\\InvokerDefault->_callObserverMethod(Object(Temando\\Shipping\\Observer\\SaveCheckoutFieldsObserver), Object(Magento\\Framework\\Event\\Observer))\n#2 /home/mage/store/vendor/magento/framework/Event/Manager.php(66): Magento\\Framework\\Event\\Invoker\\InvokerDefault->dispatch(Array, Object(Magento\\Framework\\Event\\Observer))\n#3 /home/mage/store/generated/code/Magento/Framework/Event/Manager/Proxy.php(95): Magento\\Framework\\Event\\Manager->dispatch('sales_quote_add...', Array)\n#4 /home/mage/store/vendor/magento/framework/Model/AbstractModel.php(818): Magento\\Fra in /home/mage/store/vendor/temando/module-shipping-m2/Observer/SaveCheckoutFieldsObserver.php on line 73, referer: http://store.local/checkout/

any help would be greatly appreciated

ghost commented 6 years ago

Hello @jphat , thank you for your report. I cannot reproduce this issue on clean 2.2.4 magento installation. Please use https://github.com/magento/data-migration-tool/issues to report issues related to migration from magento 1.x to 2.x.

kirkmadera commented 6 years ago

Magento's errorProcessor.process(response); should be coded to deal with an empty response. The error above is misleading. The API actually returned an empty response here. errorProcessor is trying to read it as json. It should check if the response is not empty first.

This error is coming from the fail() section of this code block in new-address.js

storage.post(
    serviceUrl, payload, false
).done(function (result) {
    rateRegistry.set(address.getCacheKey(), result);
    shippingService.setShippingRates(result);
}).fail(function (response) {
    shippingService.setShippingRates([]);
    errorProcessor.process(response);
}).always(function () {
    shippingService.isLoading(false);
});