Allow calling the cart .get()
method right after cart mutation methods
#1865
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.
WHY are these changes introduced?
Allow calling
.get()
immediately after cart mutation methods:WHAT is this pull request doing?
When calling
cart.get()
, we only make a request if a cartId exists. The problem is, someone might call a mutation method that creates the cart, and then want to get the cart. If we know the cart has been created, we can internally store the cartId in memory, and only callgetCartId()
if that internal value is undefined.HOW to test your changes?
Add
await cart.get()
right afterawait cart.addLines(inputs.lines)
in cart.ts in the skeleton template..Make sure the returned value is defined after adding an item to the cart. Also make sure that no cart exists before adding to the cart (clear cookies).
Post-merge steps
Checklist