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

Filter quantity in add_to_cart_handler_grouped #27219

Merged

Conversation

Aljullu
Copy link
Contributor

@Aljullu Aljullu commented Aug 4, 2020

Changes proposed in this Pull Request:

When adding a grouped product to the cart, pass the quantity value through the wc_stock_amount() function. This ensures the value is an integer and applies the woocommerce_stock_amount filter. This makes grouped products behavior consistent with simple and variable products.

Closes #27218.

How to test the changes in this Pull Request:

  1. Go to a grouped product page, e.g. Logo Collection from sample product data.
  2. Pick a quantity for the Hoodie with Logo and add it to the cart.
  3. Go to a single product page, e.g. Album from sample product data.
  4. Pick a quantity and add it to the cart.
  5. Now, go to the woocommerce_sessions table in the database and check the product quantities of that cart session. Verify Album's quantity as well as Hoodie with Logo's quantity are integers.

Changelog entry

When adding a grouped product to the cart, quantity is passed through the woocommerce_stock_amount filter like it's done for simple and variable products.

Copy link
Contributor

@rrennick rrennick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Aljullu Nice fix.

@rodrigoprimo rodrigoprimo self-requested a review September 12, 2020 18:56
Copy link
Contributor

@rodrigoprimo rodrigoprimo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@rodrigoprimo rodrigoprimo added this to the 4.6.0 milestone Sep 12, 2020
@rodrigoprimo rodrigoprimo merged commit 9bdafbe into master Sep 12, 2020
@rodrigoprimo rodrigoprimo deleted the fix/filter-quantity-in-add_to_cart_handler_grouped branch September 12, 2020 18:56
@woocommercebot woocommercebot added release: add changelog Mark all PRs that have not had their changelog entries added. [auto] release: add testing instructions PRs that have not had testing instructions added to the wiki. [auto] labels Sep 12, 2020
@rodrigoprimo rodrigoprimo added status: approved and removed status: needs review release: add changelog Mark all PRs that have not had their changelog entries added. [auto] labels Sep 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: cart Issues related to the cart. release: add testing instructions PRs that have not had testing instructions added to the wiki. [auto] type: bug The issue is a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Grouped products quantity is stored as string instead of integer in Cart session
4 participants