Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

120
Visualizações
How to handle shopping cart system when not login and after login?

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,

  1. When User is not logged in
  2. When User login

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 ,

  1. 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 ?

  2. 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 ?

  3. 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 !!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

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.

  1. Add a date of creation to your shopping carts. You can then experiment with either prioritizing the latest one, or asking the user to choose between their last two
  2. Merge them into one. This is very likely not what the user wants, especially if their older cart is older than, say, 24 hours.
  3. Speaking of which, shopping carts should expire. Most ecommerce platforms I've worked with usually archive the shopping carts after some time (15-60 mins). During this time they keep the items in the cart as reserved so no two people end up competing for the same stock.
  4. Expired carts can be stored so you can send an email to your user with a link that allows them to get back to their unfinished purchase.

So with that in mind, consider the following questions:

  • How relevant is each shopping cart to the user? Do you have a way of chosing the "most" relevant one?
  • Are you dealing with physical goods where you need to keep track of the stock? Then you probably need to "reserve" the appropriate amount of items for each cart, and you'd need to "expire" each cart
  • Do you ever want to present your users with a choice of two shopping carts? If yes, create an interface where they can do that. If no, consider prioritizing the latest cart and consider sending an email to the user reminding them about the earlier.

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.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda