dayhaysoos / use-shopping-cart

Shopping cart state and logic for Stripe
MIT License
907 stars 118 forks source link

Interacted With Cart State #152

Open dayhaysoos opened 3 years ago

dayhaysoos commented 3 years ago

We should have a state that allows us to temporarily show something like, "Added to your cart" for a few seconds. Not sure what I would name it, maybe hasInteractedWithCart where it's false by default. It will only display for a given number of seconds, and we can pass it a string of what it should say as well.

andria-dev commented 3 years ago

Hmm, I was thinking of a way to prototype this but I think this is the wrong way to go about something like "Added to your cart". Instead, I would recommend the developer to do this on their Product component:

They should likely be using some sort of global or global-ish state that allows them to add products to a stack when they're added to the cart. After a certain amount of time, they could be cleared off of the stack. Now that I'm writing this, we could also make this stack inside of this library.

Let me know if you want to make this stack or let the end-developers do it. For reference, if we wanted to build it we'd need to do the following: