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

Do not allow to put item in cart if available quantity is 0 #15623

Merged
merged 1 commit into from Oct 11, 2019

Conversation

@matks
Copy link
Contributor

matks commented Sep 19, 2019

Questions Answers
Branch? develop
Description? If available stock quantity is 0, refuse to add cart to product
Type? bug fix
Category? FO
BC breaks? no
Deprecations? no
Fixed ticket? Fixes #13374
How to test? See ticket, be careful about different "out of stock" behaviors (see screenshot below). Plase check with products, products with combinations and packs.

Different "out of stock" behaviors:


This change is Reviewable

@matks matks requested a review from PrestaShop/prestashop-core-developers as a code owner Sep 19, 2019
@matks matks force-pushed the matks:refuse-bad-stock-orders branch from dd35d29 to 87fd9b2 Sep 19, 2019
$this->id_product,
$this->id_product_attribute,
null,
$this->context->cart,
$this->customization_id
);
return $productQuantity < 0;
return $productQuantityAvailableAfterCartItemsHaveBeenRemovedFromStock < 0;

This comment has been minimized.

Copy link
@matthieu-rolland

matthieu-rolland Sep 19, 2019

Contributor

Is there a reason why you are using <and not <=here ?
(this method should return false if $productQuantityAvailableAfterCartItemsHaveBeenRemovedFromStock = 0 ?)

This comment has been minimized.

Copy link
@matthieu-rolland

matthieu-rolland Sep 19, 2019

Contributor

answered ! thanks

This comment has been minimized.

Copy link
@PierreRambaud
Copy link
Contributor

matthieu-rolland left a comment

lgtm !

@matks matks added this to the 1.7.7.0 milestone Sep 20, 2019
@Robin-Fischer-PS

This comment has been minimized.

Copy link

Robin-Fischer-PS commented Sep 30, 2019

@matks : The product is no longer added to cart, but the message still says "Product successfully added to your shopping cart" (you can see the test in video).
https://drive.google.com/file/d/1BfYu_pqv10wDDj69BM1igy3fDxWVvLq0/view

@matks matks force-pushed the matks:refuse-bad-stock-orders branch from 87fd9b2 to 13e549f Oct 11, 2019
@matks

This comment has been minimized.

Copy link
Contributor Author

matks commented Oct 11, 2019

@Robin-Fischer-PS Hi, you're right, but the good news is that this bug is already fixed.

The bug actually happens because of a bad behavior in module Shopping Cart (https://github.com/PrestaShop/ps_shoppingcart). This has been fixed but not yet released.

If you wish to confirm the module indeed fixes the issue, we can do 2 things:

  1. release the latest version of the module, however there is 1 mandatory PR waiting PrestaShop/ps_shoppingcart#43 so ideally we would like to wait for this PR to be completed before releasing (else, we'll need 2 releases)
  2. you can test with the latest version of the module, see below

How to test this PR with the develop version of module Shopping Cart ?

  1. Checkout the PR as you usually do
  2. Go in modules folder cd modules
  3. Remove old shopping cart module rm -rf ps_shoppingcart
  4. Git clone the repository there git clone git@github.com:PrestaShop/ps_shoppingcart.git
  5. Go into module folder, and checkout dev branch: cd ps_shoppingcart then git checkout dev

Be careful: this module adds javascript into Product page on FO. This JS will be put in cache by your browser for sure. So you need to make sure your browser cache is cleared and you use the updated version of the cart, not the previous one.

@Robin-Fischer-PS Robin-Fischer-PS self-assigned this Oct 11, 2019
@Robin-Fischer-PS

This comment has been minimized.

Copy link

Robin-Fischer-PS commented Oct 11, 2019

Hi @matks ! I tested the PR with your 2nd proposition (with the latest version of the shopping cart module), it works fine !

Thanks for the detailed walktrough 😄

@matks

This comment has been minimized.

Copy link
Contributor Author

matks commented Oct 11, 2019

@matks

This comment has been minimized.

Copy link
Contributor Author

matks commented Oct 11, 2019

Thank you @Robin-Fischer-PS and reviewers ❤️

@matks matks merged commit fe7ce1a into PrestaShop:develop Oct 11, 2019
2 checks passed
2 checks passed
PrettyCI Code formatting
Details
Travis CI - Pull Request Build Passed
Details
@matks matks deleted the matks:refuse-bad-stock-orders branch Oct 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.