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

Product can be added to cart even if the availability limit was reached #651

Closed
Algorithman opened this issue Apr 17, 2023 · 6 comments
Closed
Assignees
Labels
Milestone

Comments

@Algorithman
Copy link
Contributor

Algorithman commented Apr 17, 2023

Describe the bug
A product with a quantity of 1 and with stock limitation can be put 2 times into the shopping cart.

To Reproduce
Steps to reproduce the behavior:
In the backend:
Create a product
Set 'Manage inventory method' to 'Track Inventory'
Set Stock Quantity to 1
Set 'low stock activity' to 'Unpublish'
Set Minimum cart quantity and Maximum cart quantity to 1
Set Backorders to 'No Backorders'

In the Frontend:
Add the product to the cart
Add the product to the cart again.

Expected behavior
The product shouldn't be added a second time.

Desktop (please complete the following information):

  • OS: Windows 10 x64
  • Browser chrome

Additional context
The problem lies in the call to the cart validator in ShoppingCartService.cs line 197.
There the new quantity isn't sent to the validator since the existingCartItem's quantity wasn't updated to the new value.

This should be fixed if we move

                // Update cart item
                existingCartItem.Quantity = newQuantity;

up a few lines so the validator gets the right values.

Also when you enable "Add products to cart in single positions" then you can add the product until you reach the cart item limit.
The validator seems to need some love :)

image

@mgesing mgesing self-assigned this Apr 18, 2023
@mgesing mgesing added this to the 5.1.0 milestone Apr 18, 2023
@Algorithman
Copy link
Contributor Author

Is there a ETA on the 5.1.0 milestone?

@mgesing mgesing changed the title Limited quantity products can be added to the cart one time too much Product can be added to cart even if the availability limit was reached Apr 18, 2023
@mgesing
Copy link
Contributor

mgesing commented Apr 18, 2023

Thank you for reporting. A negative value for stock seems ok to me because that might be needed in special cases. There is no ETA for 5.1.0 yet.

@mgesing mgesing closed this as completed Apr 18, 2023
@Algorithman
Copy link
Contributor Author

Negative value for a limited quantity product also can be very unwelcome.
If you have only 1 left and can't reorder/produce again, you can't sell it twice.
There certainly are cases where it is ok, but also there are cases where it shouldn't happen at all.
If I set the inventory settings like in my image then I don't want any negative stock, that would just lead to unsatisfied/angry customers and confusion in the company why it could be oversold.

As for the bug itself, I didn't look into bundled items yet, but I think the same problem exists there.
The case with single positions in cart is easily solved with 5-10 lines of code (I did so now with my own validator) as well as the case with no single positions (also a easy fix), both cases for products with no attributes/bundles.
For the bundling and attributes I have no solution yet, but I don't need them yet either :)

@Algorithman
Copy link
Contributor Author

Algorithman commented Apr 18, 2023

And why did you close it, @mgesing ? The bug is still there.

@mgesing
Copy link
Contributor

mgesing commented Apr 21, 2023

What bug do you mean? The bug described on top of this issue was fixed by 4f1070d.

@Algorithman
Copy link
Contributor Author

Also the one when the cart is set to single items?
Same problem exists there and probably also for bundles.

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

No branches or pull requests

2 participants