[Backport] issue/14056 - Coupon API not working for guest user #16782
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.
Original Pull Request
#15320
issue/14056 - Coupon API not working for guest user
#14056
Description
This is a forward port for the following PR: #15320
I think everything is fine with the code. Reason is that programmers don't use API properly. With 1 step when cart is being created it's already wrong because quote doesn't contain proper store id. When cart is being added by API it has store id 0. So instead of adding by
/rest/V1/guest-carts (which is standard in swagger)
we should use
/rest/default/V1/guest-carts
By using store code in URL we provide store id to quote.
Then coupon code added by API works like charm.
So reason is some kind of ignorance. We've decided to provide better validation message while adding coupon code to inform programmer that he has wrong quote and that problem is rather there.
I think that some example would be useful in API documentation to show how to use API properly.
Fixed Issues (if relevant)
Manual testing scenarios
Contribution checklist