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

Set maximum Qty Allowed in Shopping Cart is 0 still allow adding to cart #18477

Closed
duongdiep212 opened this issue Oct 9, 2018 · 10 comments
Closed
Assignees
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@duongdiep212
Copy link

duongdiep212 commented Oct 9, 2018

Preconditions

  1. Magento Open Source and Commerce 2.2.x
  2. PHP 7.1
  3. Sample data is installed

Steps to reproduce

  1. Click to edit simple product, then click "Advanced Inventory ", enter 0 in "maximum Qty Allowed in Shopping Cart" field
  2. Go to front-end and add this product to cart.

Expected result

Show message can not add qty to cart : The most you may purchase is 0.

Actual result

Still adding qty to cart with no limit.

@magento-engcom-team
Copy link
Contributor

Hi @duongdiep212. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me $VERSION instance

where $VERSION is version tags (starting from 2.2.0+) or develop branches (for example: 2.3-develop).
For more details, please, review the Magento Contributor Assistant documentation.

@duongdiep212 do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Oct 9, 2018
@duongdiep212
Copy link
Author

duongdiep212 commented Oct 9, 2018

I checked core and found the function below :
if ($stockItem->getMaxSaleQty() && $qty > $stockItem->getMaxSaleQty()) { $result->setHasError(true) ->setMessage(__('The most you may purchase is %1.', $stockItem->getMaxSaleQty() * 1)) ->setErrorCode('qty_max') ->setQuoteMessage(__('Please correct the quantity for some products.')) ->setQuoteMessageIndex('qty'); return $result; }
you can see it in : vendor/magento/module-catalog-inventory/Model/StockStateProvider.php

The problem is when I set max qty = 0, so $stockItem->getMaxSaleQty() return false in this condition , that means it will pass through this function and allow you adding to cart with no limit.

@pocallaghan
Copy link
Contributor

Out of curiosity, what's the use case for having a value of 0 for max sale quantity?

@gelanivishal
Copy link
Contributor

Yes. We can fix it by Maximum Qty Allowed in Shopping Cart is greater than 0. Let me try it

@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Oct 9, 2018

Hi @gelanivishal. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 6. Add label Issue: Confirmed once verification is complete.

  • 7. Make sure that automatic system confirms that report has been added to the backlog.

@tomekjordan
Copy link

Out of curiosity, what's the use case for having a value of 0 for max sale quantity?

probably using product in some "catalog" mode without purchasing. but still holding some stock for admin orders etc

@sidolov
Copy link
Contributor

sidolov commented Oct 12, 2018

Hi @duongdiep212. Thank you for your report.
The issue has been fixed in #18481 by @gelanivishal in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.1 release.

@sidolov sidolov added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Oct 12, 2018
@sidolov
Copy link
Contributor

sidolov commented Oct 13, 2018

Hi @duongdiep212. Thank you for your report.
The issue has been fixed in #18552 by @gelanivishal in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.8 release.

@duffner
Copy link

duffner commented Jul 4, 2019

Team,

In addition to #23319 , the use case for 0 in the world of Magento is a value for infinite. Now instead of setting 0, we have to set some artificial number that’s quite high. There’s no such thing as 0 allowed in cart. If there’s a use case for not allowed, the product should be out of stock.

Please advise.

@duffner
Copy link

duffner commented Jul 4, 2019

I vote on reverting this commit. If we are not going to revert, please provide solution for not restricting the max amount in the cart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests

7 participants