I'm in the process of writing a simple shop for my business, and I'm currently implementing the
cart logic. I use vanilla JS in the client side and communicate with the server via JSON API, I
render everything in the client side.
From my research online, I discovered that some online shops maintain the user cart in their database, so to add/remove/modify an item, you need to send an HTTP request to the server. I don't want to do that, because of the overhead and my idea is to maintain the cart in localStorage and on checkout, send the whole cart at once.
Is this a good idea? What issues can occur when managing a shopping cart in the client side?
I am asking that because I assume there is a reason many online shops manage the user cart in
their database (apart from collecting data on users)
Thanks.
question from:
https://stackoverflow.com/questions/65900529/implementing-shopping-cart-using-localstorage 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…