Fix mini-cart not emptied for logged out users checking out with PayPal Express #9994
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.
Description
When checking out of M2 using PayPal Express as a logged in user, the mini-cart is not emptied after you reach the success page. In fact, you'll still have the same cart contents in the mini-basket as you purchased. As soon as you add a new item to the basket it does then reset and only shows the new items (old contents are gone). This is, however, confusing, as clicking the mini-cart then proceeding to cart of course shows "No items in the cart".
There are two modules providing API for setting payment information,
Magento_Quote
andMagento_Checkout
. The former,Magento_Quote
has entries insections.xml
to invalidate and reload thecart
data. In this code it is usingMagento_Checkout
for guests andMagento_Quote
for logged in users, causing logged in users to have theircart
data reloaded too early, before the cart is in fact reset, and causing it to persist after checkout is completed. By modifying this to useMagento_Checkout
APIs for both (as one would likely expect) the issue is resolved, as there are nosections.xml
entries for theMagenta_Checkout
APIs.This PR also introduces consistency as the same module API is used for both types of users.
I'm unsure how to make integration tests for this.
Manual testing scenarios
Before PR: You will see items still in mini-cart even though you bought them
After PR: You will see an empty mini-cart
Contribution checklist