checkitout
checkitout copied to clipboard
Changes to fields are not saved to the server while an ajax request is in progress
Because a step does not send data to the server if it is already in the process of sending data then there is the possibility of the data that the user sees in the checkout being out of sync with the data that the server holds.
This causes support issues when the user thinks that they have specified one thing, like ship to France but Magento has another, like ship to the UK
This situation can easily be observed on a development environment where caching is switched off; meaning ajax request take longer than on a live environment
To recreate:
- Uncheck "Use same address for shipping"
- select "New address"
- ensure the rest of the form is ready for submission
- type in the address field and wait for the saveShipping ajax to fire (visible in the network tab of browser's developer extension)
- while ajax is being submitted change the country
- submit the order
Viewing the order in Magento will show that the change of country was not saved
A solution to this problem would be to do the following:
- change the step's this.updater to be an intermediate method which then calls the this.submit() method
- change the onComplete and onFail callbacks to intermediate method as well
- the updater intermediate method could then call the this.submit() method if its not already submitting otherwise flag that the this.submit() method needs to be re-called after completion/failure of the current request
- the onComplete and onFail intermediate functions can then clear flags and re-call the this.submit() where required