Webshop without login: add a product two times two the cart

Hello! Im stuck with a problem. I created a simple webshop where the visitor can buy stuff without registration.
I work on the “current user” option and added a “cart” which is a list of products to the user. The button add will add x product to the cart list of the current user. The problem is that I can not add the same product twice to this list.
Any workaround or advice in how to structure the db to be able to have a webshop without registration? Ps, the current user will add their name and email at checkout only for delivery purposes. Thanks for any directions on this…

You need to make a new datatype Order Item with fields for the Product (Product) and Qty (number)

Then when they click add to cart you have two workflows on the same button, one checks for if an Order Item exists with that product already, if so add 1 to the Qty.

The other checks if it doesn’t exist, if so it makes a new Order Item with that Product with a Qty of 1.

Genius. Simple but effective. Many thanks for the advice.

1 Like

These Order Items would be the eventual items for your Order datatype, so once the order goes through set a Order field on each item. Prob would want a price field too so even after the product price changes the Order Item still has the original price when the user purchased it.

Then you can also filter by if an Order Item has an empty Order to determine if it actually went through or if you can do garbage collection later and delete it if it is X weeks old.

ok thanks again. Changing the DB structure and creating the Order as you suggested. Thanks!!