Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
398 views
in Technique[技术] by (71.8m points)

javascript - Implementing shopping cart using localStorage

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...