adding product to cart function won't work when there are more than one product in cart
Unanswered
Pacific cod posted this in #help-forum
Pacific codOP
Hi
I made a cart hook with zustand and there I add product to the locale storage. Everything works fine when there is only one product in the cart but when I add anoter one all functions either won't work or work in a way that is not intended. For example when there is one product in the cart and I add another one, the new one replace the old one. or the Plus button which increase the product quntity won't work on one of the product but it works fine on the other one. Or the Trash Button sometime works fine and delete the intended product or somtimes it deletes all products.
This is a gist that contains the zustand hook and add to cart button
https://gist.github.com/rezarahem/70ffa69584f1cdd5fcd903d8245caa8f
I made a cart hook with zustand and there I add product to the locale storage. Everything works fine when there is only one product in the cart but when I add anoter one all functions either won't work or work in a way that is not intended. For example when there is one product in the cart and I add another one, the new one replace the old one. or the Plus button which increase the product quntity won't work on one of the product but it works fine on the other one. Or the Trash Button sometime works fine and delete the intended product or somtimes it deletes all products.
This is a gist that contains the zustand hook and add to cart button
https://gist.github.com/rezarahem/70ffa69584f1cdd5fcd903d8245caa8f