Persisting cart Items on my e-commerce website - mongodb

I'm planning on an e-commerce website and would like some help!
The functionality I want is that whenever a user logs in, I will use the user's email address to fetch from my MongoDB database to retrieve all of the user's cart information (what the user has put in his/her cart from last time). However, I worry that if the user accidentally closes their tab, or closes their window, and visits the website again, then I would need to fetch from my database again to get the cart items. My question is that would it be better to store the cart item on a local storage or session storage. And then, once the user goes to the checkout page, I then store all of the cart items back to database. In that way, I don't need to store to and retrieve from the database everytime the user adds an item to the cart.
I'm using React/MongoDB. This is my first time building a e-commerce website and I would like to know how other people usually handle this problem, and whether local storage, session storage, or there are other ways to handle this!

Related

Redirect Firebase Push notification

I am working on an App that has number of vendors providing offers and discounts on their product.
I am able to send notification but i want user to be redirected to a details page where vendor's information from firebase cloud firestore is dynamically loaded to that particular details page.
I want to know how do I send firebase collection documents with notification
i think you should send collection name as a data in notification so that when received notification you can extract collection name from data.

Where should I keep data to continuously use in server?

Currently, I'm trying to build a dating app(server part).
I'm going to store each user's profile data like videos, photos, profile messages to AWS S3.
And I have user info including location(longitude, latitude) in my database server.
If you've ever used this kind of app, you might easily understand how it works.
First, whenever a user opens this app, the user gets to see the profile of other users one at a time based on the current location.
Second, the user gives like or dislike to the current profile and gets to the next profile.
So, in order to implement the first step, I'm going to search other users in a certain distance from the user's current location in the database, but here I'm only going to get unique user ID values from database. This only happens once when a user opens the app.
Now that I have other users' id values like [id1, id2, id3, id4...] I can load each user's profile data from AWS S3 with each unique id value one by one whenever the user needs to see the next profile.
Here my question comes. To build the recommendation logic like that, where should I keep the id values??
Thanks in advance.
Use a in memory cache like Redis/memcache (both provided by AWS). Also your cahce should get updated as and when data in AWS S3 profile updates because only then you will have latest data.

Firestore chat private and group

I have this chat structure for groups and private in real time, is there any way to structure to get the images and names of the people who chat? currently using UserIds I do a separate query to get it, but if someone changes their name or image it won't update.
You typically would start a RTDB listener for the nodes of the RTDB that contain the information for each of the users. Alternatively, you could copy all of the relevant user information into "current chats" and if a user changes their profile information you could also copy that new information into any "current chat" sessions.
In my app, I maintain user profile information in a profile collection in Firestore, and maintain the chat details in RTDB. So I have a realtime listener for the chat (RTDB) and a realtime listener for firestore.collection('profile').where('uid', 'in', arrayOfUserIDsInChat).
(Currently the way I have things, I am limited to the number of user profiles I can listen to ... in is limited to 10 ... but that is sufficient for my current requirements)

What is the correct process of keep consistency of data at add to cart functionality when using flutter_bloc?

I am implementing add to cart functionality in a flutter app with using BLoC pattern as state management, only a user who is logged can add products to the cart and as the first step, I want to store that cart data locally before trigger a POST request to the database. Also, there should be a facility to user to remove items from cart if it's unnecessary. Further, I want to keep the cart in the same state after a user re-open the application who logged in before. Is it possible with flutter_secure_storage and how I do in a proper way? And, how I maintain a cart to each user?
You can store the items of the cart in some persistent database or storage, so when the user opens the app again the items would be pre-loaded in the cart bloc. For this purpose, you can use the Hive, Shared Preference or sqflite. Use which one works best for you.
The proper way would be to store items in storage right after the user adds them, and clear the storage right after the user clears its cart, so he does not see any previous item upon opening the app next time.
Maintaining the cart for each user in persistent storage should not be a problem as it is stored in the mobile's memory. But if you are asking for multiple users using the same device having different cart items then you can assign a unique id or value to identify which user has logged in.

How to add notify me functionality on pdp page in demandware

Hello I am new to demandware just worked on few POC's and I need to create a notify button on pdp page if a product is out of stock then on clicking this button a pop up window will open which will ask for email id that should be saved in a custom object and the user should be alerted when the product comes in stock via email that has been saved in custom object
Generally you should rely on a third party system (usually the OMS or some other back-end system) to store and send notifications. The mechanism I've seen used most often to achieve this is to record the product ID, customer email address, and timestamp into a Custom Object. Periodically these Custom Objects should be exported to the third party system via a job and then deleted from the Demandware system. Deletion is important because of system quotas limiting the total number of Custom Objects than can be stored.
The third party system would periodically look at the the products that have been 'subscribed' to, if they have inventory, then email the people who wanted to be notified.
What you can do is create a simple button on PDP upon clicking which, a popup box is shown which contains a form with hidden pid field and a text box for entering user's email, and a submit button to submit this information.
Use jQuery and AJAX to get the form data (pid & email), pass this on to Controller, store the data into custom object, get the response back from the Controller, and show the response back on the popup or in any other way you feel fit.
You'd need to create custom object to store this data, wherein your unique key would be combination of email and pid (encryption recommended).