[Woo POS] Ensure auto-draft order removal on exit POS #15975
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes WOOMOB-88
Description
This PR addresses
.autodraft
orders not being deleted from storage when we exit POS after checkout, but before completing a payment.The draft order is created in local storage when we perform
POSOrderService.syncOrder()
, and should be cleared after collecting a payment and starting a new order. The issue is thatclearOrder()
, triggered on exiting POS, only clears the in-memory order reference but doesn't delete the autodraft order from the local storage/database. So if payment is not finished and switches the order status, then the autodraft order remains persisted in CoreData until manually refreshed (we can see it disappear as soon as we pull-to-refresh in order list)Changes
clearOrder()
on exiting POS, if we're holding a reference to an order and this is set to autodraft (which only happens between checkout and payment collection) then we delete it.Steps to reproduce / Testing information
My iPad seems to have died, so I used a physical iPhone and removed the ipad/width restrictions for testing. Sorry for the video!
auto-draft.auto-removed.mp4
RELEASE-NOTES.txt
if necessary.