I am building a shopping cart system, but I am quite confused with how to build it properly when it comes to this two situation,
So in first situation I can use local storage to manage the data, and the second, I can use database to store the user's shopping cart , but here come the problem ,
if User add something when not log in , but he already has different items in their database shopping cart , I can just add them together or replace the local storage shopping cart with database one ?
As I said if I use two different strategy , before each shopping cart related function, I should add "if user is login " to decide it would send by API or just store the data in local storage , is it really a proper approach ?
If above is not the good approach , then how should I structure my project ?
I am not really familiar with real world web design , and I watch a few shopping cart tutorial , I don't think they cover enough ground for real production , maybe someone can provide a good real production example using React + NodeJS , I would be much appreciate !!
This sounds like a business decision. Get your product people and your UX people involved.
If you don't have those, there are multiple things you could do.
So with that in mind, consider the following questions:
Your problem is with having too many options, not with having no choice, so you need to either get your peers involved, or start A/B testing. I think you'll only get subjective answers here.