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

Update onAdd and toggleCartItemQuantity #29

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ms097530
Copy link

Reset qty to 1 at the end of onAdd. This prevents the previous value of qty from carrying over between different product pages.
Also used Array.map to update quantity changes in the cart and maintain ordering.

Reset qty to 1 at the end of onAdd. This prevents the previous value of qty from carrying over between different product pages.
Also used Array.map to update quantity changes in the cart and maintain ordering.
@vercel
Copy link

vercel bot commented May 29, 2022

Someone is attempting to deploy a commit to a Personal Account owned by @adrianhajdin on Vercel.

@adrianhajdin first needs to authorize it.

@F00r3y3s
Copy link

F00r3y3s commented Aug 8, 2022

Hello ms097530,

adding setQty(1); did solve half the issue. it does set the value back once u choose a quantity let us say 4 and click add to cart

but if u choose the quantity 4 and do not click add to cart and browse to a different product the value does not set back to one it remains 4

your solution does work { if the add to cart button is clicked } but it does not set the value back to 1 if add to cart is not performed and browse to a different product.

can you plz look into that? thanks

@LordRekishi
Copy link

Hello ms097530,

adding setQty(1); did solve half the issue. it does set the value back once u choose a quantity let us say 4 and click add to cart

but if u choose the quantity 4 and do not click add to cart and browse to a different product the value does not set back to one it remains 4

your solution does work { if the add to cart button is clicked } but it does not set the value back to 1 if add to cart is not performed and browse to a different product.

can you plz look into that? thanks

You can get the setQty function from StateContext in your Product component and set it to 1 onClick when clicking the link to go to the ProductDetails page

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

Successfully merging this pull request may close these issues.

3 participants