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

Fix error processor breaking checkout when a shipping request fails #580

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sippsolutions
Copy link
Contributor

When a request fails during the shipping step (before the payment step) and does not return valid JSON, the error processor mixin fails because responseJSON is undefined:

error-processor-mixin.js:52 Uncaught TypeError: Cannot read properties of undefined (reading 'hasOwnProperty')
    at Object.<anonymous> (error-processor-mixin.js:52:51)
    at Object.process (wrapper.js:78:32)
    at Object.<anonymous> (fee-service.js:64:32)
    at fire (jquery.js:3223:50)
    at Object.fireWith [as rejectWith] (jquery.js:3353:29)
    at done (jquery.js:9629:30)
    at XMLHttpRequest.<anonymous> (jquery.js:9888:37)

Additionally, quote.paymentMethod() is not given within shipping step, which also fails even if we fix the the first issue.

This currently results in the loading screen remaining visible and prevents checkout in some cases (especially with custom functionality in the shipping step).

This issue can be resolved with minimal changes by using optional chaining: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining

@janteuber
Copy link
Contributor

Hello @sippsolutions ,

Thank you so much for creating the pull request on GitHub. Our developer will review it shortly, and we will get back to you with feedback afterward.

Best regards,
Jan

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

Successfully merging this pull request may close these issues.

2 participants