-
Notifications
You must be signed in to change notification settings - Fork 70
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
Fix incorrect quantity when product is already in cart #421
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing it @martynmjones. I tested both block and classic shops and it worked as expected. I'm approving this but just left a comment regarding the E2E test.
const addToCart = `.single_add_to_cart_button[value="${ simpleProductID }"]`; | ||
const addToCartButton = await page.locator( addToCart ).first(); | ||
|
||
await addToCartButton.click(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❔ What do you think adding a page.reload()
for the classic shop as well so it would match the testing instruction in the PR description?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review @ianlin 🙌
The error with the product quantity on the single page wasn't triggered with a page reload in the same way the other one was. When the added_to_cart
hook runs the quantity wasn't being added to the product object so for the test we just need to click the Add to cart
button and then confirm the quantity is now present in the event. Apologies if that wasn't clear from the testing instructions.
Changes proposed in this Pull Request:
Closes #391
Adjusts the utility to retrieve a product by its ID to prioritise the product data object over the cart object. This is to prevent the existing cart quantity from being sent with an
add_to_cart
event.Additionally, the function to format product data is updated to pass along the quantity on the
added_to_cart
event.Detailed test instructions:
fix/391-incorrect-product-quantity
and build the extension1
4
and add it to cart4
Changelog entry