ecommerce_sanity_stripe icon indicating copy to clipboard operation
ecommerce_sanity_stripe copied to clipboard

Update onAdd and toggleCartItemQuantity

Open ms097530 opened this issue 2 years ago • 3 comments

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.

ms097530 avatar May 29 '22 21:05 ms097530

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

@adrianhajdin first needs to authorize it.

vercel[bot] avatar May 29 '22 21:05 vercel[bot]

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

F00r3y3s avatar Aug 08 '22 13:08 F00r3y3s

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

LordRekishi avatar Apr 10 '23 10:04 LordRekishi