Skip to content
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

Coupon code is not valid error when using REST API - Magento CE 2.17, 2.1.8 2.1.9 #11259

Closed
coleHafner opened this issue Oct 5, 2017 · 5 comments
Assignees
Labels
Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Progress: needs update

Comments

@coleHafner
Copy link

Summary

When applying a coupon code to a qualifying cart (ie cart that has the items in it to which the specific coupon code applies), the coupon code is denied. The system returns a 500 error "Coupon code is not valid".

Preconditions

  1. Magento Open Source version 2.1.9 (also experienced this error on 2.1.7 and 2.1.8) - No plugins/modules enabled.
  2. Ubuntu version 14.04.5
  3. Nginx version 1.10.2
  4. PHP version 7.0.14
  5. Mysql version 14.14

Steps to reproduce

  1. Create a new guest cart POST: https://domain.com/V1/guest-carts
  2. Add item(s) to cart POST: https://domain.com/V1/guest-carts/<cart id>/items
  3. Apply discount code: PUT: https://domain.com/V1/guest-carts/<cart id>/coupons/<coupon code>

Expected result

  1. 200 response. Discount should be applied to the cart totals.

Actual result

  1. 500 response. "Coupon code is not valid" message returned.

I've tracked this down to the CouponManagment class When it saves the quote, the coupon code disappears. It has to be something with the cart rules not being properly recognized for the products in the cart.

Here is my cart rule
Websites: Main Website
Customer Groups: All
Coupon: Specific Coupon
Coupon Code:
Uses per Coupon: 500
From: 9/17/17
To: 10/10/17

Conditions: All products

Actions
Apply: Percent of product price discount
Discount Amount: 5.236
Maximum Qty: 10
Discount Qty Step: 0
Apply to Shipping: No
Discard subsequent rules: No
Free Shipping: No

Apply the rule when...
If ALL of these conditions are TRUE:
Category is one of 4, 36, 37, 39, 40, 41, 135

I know this has something to do with the category structure because when I simply remove/add one of the eligible categories to the product, it works just fine. Perhaps the category structure itself is breaking the rule?

| Default Category
| -- Category 1
| -- Parent Category
| --- Child Category 1
| --- Child Category 2
| --- Child Category 3

All items have Child Category 1, 2, or 3 applied. Like I said, when I add (or remove) Parent category, the rule applies just fine.

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Oct 5, 2017
@okorshenko okorshenko added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Oct 5, 2017
@magento-engcom-team
Copy link
Contributor

@coleHafner Thanks for reporting this issue.
Unfortunately, I could not reproduce the issue as you described it.
Steps I did:

  1. Create Categories:
    categoriees
  2. Create simple product "s1" and assign it to category Child Category 1
  3. Create Cart Price Rule with coupon = 'test' and conditions in actions:
    rule conditions
  4. Make requests:
 {
   "cartItem": {
     "sku": "s1",
     "qty": 1,
     "name": "s1",
     "product_type": "simple",
     "quote_id": "cartId"
    }
 }

Result: coupon was applied without errors.
Please add more details to your description of the steps you followed when identifying this issue. Screenshots or logs would be helpful, too.

@magento-engcom-team magento-engcom-team self-assigned this Oct 6, 2017
@magento-engcom-team magento-engcom-team added Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Progress: needs update labels Oct 6, 2017
@coleHafner
Copy link
Author

Thank you for your response. The only additional details I can give is that the parent category was part of the cart rule as well as the child categories. I don't think that would make a difference, but maybe.

@magento-engcom-team
Copy link
Contributor

@coleHafner Thanks for the feedback.
Did with parent category as a part of the cart rule.
screenshot_1
Unfortunately still can't reproduce this issue. Coupon applied successfully.
If You can provide additional details, feel free to post it here, so we can try to reproduce this issue with new details.

@magento-engcom-team
Copy link
Contributor

@coleHafner we are closing this issue due to inactivity. If you'd like to update it, please reopen the issue.

@tuyennn
Copy link
Member

tuyennn commented May 2, 2018

This one related to Coupon API not working for guest user #14056

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Progress: needs update
Projects
None yet
Development

No branches or pull requests

4 participants