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

Add element to cart keep same quantity #89

Open
MarcosMene opened this issue Dec 13, 2022 · 3 comments
Open

Add element to cart keep same quantity #89

MarcosMene opened this issue Dec 13, 2022 · 3 comments

Comments

@MarcosMene
Copy link

MarcosMene commented Dec 13, 2022

Hello.
If I buy a product, I select quantity 2 and click Add to Cart button, il will appears 2 products at the bag. Ok it works great.
But if I decide to buy another product. I click another product and it keeps the same quantity value of the first product. I need to change the value quantity to chose just 1 product.
Does it happen with you too?

@Wullink
Copy link

Wullink commented Dec 17, 2022

Same problem here. Have you found a solution?

@adhishVerma
Copy link

Hello. If I buy a product, I select quantity 2 and click Add to Cart button, il will appears 2 products at the bag. Ok it works great. But if I decide to buy another product. I click another product and it keeps the same quantity value of the first product. I need to change the value quantity to chose just 1 product. Does it happen with you too?

It's supposed to do that. and it's because of the way we've set the quantity, inside stateContext we change the quantity to what we want with the plus and minus options on the product page, and it is not reset when we add the item to the cart.
If you want to reset that, you will have to reset the qty, with setQty method.
If you want to reset after adding items to the cart, u have to put it inside the event handler of the cart button.
If you wanna do that if you move to some other product page, then I think you can use the useEffect hook.

@Jibrand
Copy link

Jibrand commented Jun 21, 2023

I can solve this, please allow me to fork the project.
Thankyou,

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

No branches or pull requests

4 participants