Skip to content

[Backport] issue/14056 - Coupon API not working for guest user #16782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

gelanivishal
Copy link
Contributor

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)

  1. Coupon API not working for guest user #14056: Coupon API not working for guest user

Manual testing scenarios

  1. Create guest cart by API
  2. Add product to cart by API
  3. Create coupon and rule in admin panel
  4. Add coupon to cart by API
  5. See exception "Coupon code is not valid"

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team magento-engcom-team added this to the Release: 2.1.15 milestone Jul 13, 2018
@sidolov sidolov changed the title [Backport] Add compare list link to success message after adding a product [Backport] issue/14056 - Coupon API not working for guest user Aug 14, 2018
@magento-engcom-team magento-engcom-team merged commit bc749b0 into magento:2.1-develop Aug 14, 2018
magento-engcom-team pushed a commit that referenced this pull request Aug 14, 2018
@magento-engcom-team
Copy link
Contributor

Hi @gelanivishal. Thank you for your contribution.
We will aim to release these changes as part of 2.1.16.
Please check the release notes for final confirmation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants