ecommerce_sanity_stripe
ecommerce_sanity_stripe copied to clipboard
Update onAdd and toggleCartItemQuantity
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.
Someone is attempting to deploy a commit to a Personal Account owned by @adrianhajdin on Vercel.
@adrianhajdin first needs to authorize it.
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
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