Add Item(s) to Database for the Session

Is there any way to add items from a Repeater to the Database just for the session.

Example: A user comes on my website and adds an item to the Database from a Repeater by clicking the ‘Add to Cart’ Button.

If he navigates to the Cart Page while in the same session, he will see his items in the Cart Page displayed within a Table.

If he exits, the Items are removed from the Database.

Is this possible ?

Hi,

You can use the wix-storage API. Either save the session data using wix-storage, or keep a flag indicating that the user’s data should be kept or discarded.

Good luck,

Yisrael

save the session data using wix-storage
How can I do that ? Do you have an example ?

More importantly, how will the database handle multiple users on the same page at the same time adding items to the cart?

wix-storage - see the examples in the API docs

Hey,

you’ve figured it out?

I am try to make addToCart without user login and use Sessions.

let $item = $w.at(event.context);
                clickedItemData = $item("#datasetProduct").getCurrentItem();
 let CompareItems = {
                    product: clickedItemData._id
                };
 
                console.log(CompareItems)
                session.setItem('ProductID', CompareItems)
 
 let value = session.getItem("ProductID");
                console.log(value);