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

[Magento 2.1.2] Wrong error message in cart after entering invalid discount code with product stock qty = 1 (only for simple variant products) #7230

Closed
LucScu opened this issue Oct 28, 2016 · 13 comments
Labels
bug report Component: Checkout Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@LucScu
Copy link

LucScu commented Oct 28, 2016

Tested on last magento 2 version 2.1.2 and Luma sample data.

Preconditions

  1. Set a simple variant product qty to 1.

    With sample data i used

    http://luma.kamiceria.com/tiffany-fitness-tee.html

    with blue color and xs size (sku WS09-XS-Blue)

Steps to reproduce

  1. Add above product WS09-XS-Blue to cart
  2. Go to cart
  3. Add invalid discount code like 'xxx'

Expected result

  1. Magento shows error message

    'The coupon code "xxx" is not valid.'

Actual result

  1. Magento shows error messages

    'The` coupon code "xxx" is not valid.' ->OK

    'We don't have as many "Tiffany Fitness Tee" as you requested.' ->BUG
@olysenko
Copy link

olysenko commented Nov 1, 2016

Hi, thank you for your reporting. Internal ticket is created MAGETWO-60352

@olysenko olysenko added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development and removed in progress labels Nov 1, 2016
@olysenko olysenko removed their assignment Nov 1, 2016
@LucScu
Copy link
Author

LucScu commented Dec 1, 2016

Ok the bug is reported, but when you fix it?

@olysenko
Copy link

olysenko commented Dec 1, 2016

Unfortunately, we don't have time estimates for this bugfix now

@LucScu
Copy link
Author

LucScu commented Dec 1, 2016

Thank you, i hope you find the time to fix it asap.

@LucScu
Copy link
Author

LucScu commented Jan 11, 2017

Do you know if this bug is fixed on 2.1.3?

@thelettuce
Copy link
Contributor

Can confirm the problem still happens in 2.1.3.

@thelettuce
Copy link
Contributor

It seems to be if there is not 2 * the number of items in your cart in stock, then the error happens.
eg.
if the item qty in-stock is 6 then
if you have 3 items in your cart and enter invalid discount there's no error.
if you have 4 items in your cart and enter invalid discount you get the error.

probably to do with the discount function copying the cart or something.

@eInyzant
Copy link

Hi I have a similar issue, and it seems related.
I have a product with stock qty = 6.
I add this product to my cart with qty more than 3 (eg: 4)

Now I add another product.

It seems that magento will perform several qty check for items, and each loop will add double qty.
I don't know exactly but here one of my trace :

#0  Magento\Quote\Model\Quote\Item->setQty() called at [/httpdocs/vendor/magento/module-quote/Model/Quote/Item.php:325]
#1  Magento\Quote\Model\Quote\Item->addQty() called at [/httpdocs/vendor/magento/module-quote/Model/Quote/Item/Processor.php:100]
#2  Magento\Quote\Model\Quote\Item\Processor->prepare() called at [/httpdocs/vendor/magento/module-quote/Model/Quote.php:1617]
#3  Magento\Quote\Model\Quote->addProduct() called at [/httpdocs/vendor/magento/module-quote/Model/Quote.php:1722]
#4  Magento\Quote\Model\Quote->updateItem() called at [/httpdocs/vendor/magento/module-quote/Model/Quote/Item/CartItemPersister.php:72]
#5  Magento\Quote\Model\Quote\Item\CartItemPersister->save() called at [/httpdocs/vendor/magento/module-quote/Model/QuoteRepository/SaveHandler.php:69]
#6  Magento\Quote\Model\QuoteRepository\SaveHandler->save() called at [/httpdocs/vendor/magento/module-quote/Model/QuoteRepository.php:161]
#7  Magento\Quote\Model\QuoteRepository->save() called at [/httpdocs/vendor/magento/module-checkout/Model/Cart.php:574]
#8  Magento\Checkout\Model\Cart->save() called at [/httpdocs/app/code/TeoJasmin/Catalog/Plugin/Magento/Checkout/Controller/Cart/Add.php:151]

Then magento will call "sales_quote_item_qty_set_after" event and check for quantities in

  • Magento\CatalogInventory\Model\Quote\Item\QuantityValidator

So for example :
I add my product1 with quantity 6. (this product has a stock qty of 6)
In my quote, I can see the item1 with quantity 6.

Now when I a product2 with quantity whatever (eg: 1), if I do some logging in QuantityValidator::validate (around line 64) the first time the qty of item1 is 6, and after it will be 12...

I think Magento should not double check, and moreover should setQty instead of add qty to existing item qty.

Hope this will help to track down this bug...

@LucScu
Copy link
Author

LucScu commented Apr 7, 2017

@veloraven
@olysenko
@allMagentoStaff
just say that we have to fix your (billions) bugs by ourself!

@pixiemediaweb
Copy link

Any feedback from the Magento team on this one yet?

@pixiemediaweb
Copy link

pixiemediaweb commented May 12, 2017

I've found a configuration work-around for this bug.

In Stores > Configuration,
Catalog > Inventory

Product Stock Options: Backorder 'allow qty below 0'.

As long as you are still managing stock and hiding out of stock products, the user will still be able to add products with 1+ stock to basket and the promo code issue wont present itself.

Once the product reaches zero stock it will go to out of stock and not be available as usual.

Its a plaster though which has potential for a user to add a higher quantity than you have in stock, so we still need a core update from Mage.

@LucScu
Copy link
Author

LucScu commented Jun 27, 2017

@tomdollarmpd Sure we need that magento team fix it asap.
@olysenko Please reassign this issue to a magento staff user.

magento-team pushed a commit that referenced this issue Jul 5, 2017
MAGETWO-69029: Remove obsolete link "Show more" on Dashboard page on Advance Reporting block
MAGETWO-60352: [Github] Wrong error message in cart after entering invalid discount code #7230
MAGETWO-66510: Javascript error prevents adding/removing categories from existing catalog price rule condition
MAGETWO-59207: Checkbox return to stock doesn't work if Automatically Return Credit Memo Item to Stock Yes
MAGETWO-70201: Update Readme for Analytics modules. Final
MAGETWO-57835: [Github] Cannot save customer dob attribute if admin interface locale is en_GB #6323
@magento-engcom-team magento-engcom-team added 2.1.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Component: Checkout Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed labels Sep 11, 2017
@magento-engcom-team
Copy link
Contributor

@LucScu, thank you for your report.
The issue is already fixed in 2.2.0

magento-team pushed a commit that referenced this issue Oct 3, 2017
magento-team pushed a commit that referenced this issue Oct 3, 2017
magento-team pushed a commit that referenced this issue Oct 3, 2017
magento-team pushed a commit that referenced this issue Oct 3, 2017
magento-team pushed a commit that referenced this issue Oct 3, 2017
magento-team pushed a commit that referenced this issue Oct 3, 2017
magento-team pushed a commit that referenced this issue Oct 3, 2017
magento-team pushed a commit that referenced this issue Oct 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Checkout Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests

7 participants