Best Practices for saving and loading cart items

Hi All!

What would be the best way of saving and loading cart items?

Currently what I did is when the user adds a product, the product ID will be saved in the DB. Then on my cart page I am fetching all of the product ID to get the details of each product.

Or should I save all the details of the product that has been added to the cart?

I’m using MongoDB as my database, and I’m working on a mobile app.


I mean it really depends on the architecture of the app. I would vote against this at all and would suggest only to store cart items in the browser.

yes I can save it to the browser, the problem with that is when the user logged in using different phone.

The scenario is, I want the cart items to be viewed when the user logged in in different phone.

This is classic “cat-and-mouse game” situation. You need an user account in order to achieve that which slows time-to-goal and possibly hurts business logic. If you will create “anonymous” account to fight that then you will revert back to the same problem: how would you link one anonymous account between devices?