Skip to content

Update onAdd and toggleCartItemQuantity#29

Open
ms097530 wants to merge 1 commit into
adrianhajdin:mainfrom
ms097530:ms097530-patch-1
Open

Update onAdd and toggleCartItemQuantity#29
ms097530 wants to merge 1 commit into
adrianhajdin:mainfrom
ms097530:ms097530-patch-1

Conversation

@ms097530

Copy link
Copy Markdown

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

vercel Bot commented May 29, 2022

Copy link
Copy Markdown

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

@adrianhajdin first needs to authorize it.

@F00r3y3s

F00r3y3s commented Aug 8, 2022

Copy link
Copy Markdown

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
Copy Markdown

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