Hey @charleshope, I think you misunderstood the question.
So @Marino Just a quick basic breakdown of how to make a shopping cart work well (as outlined in my Point of Sale template)
You need 4 database collections: Stores, Products, Order Items, and Orders.
Stores relationship with products where stores can have many products, products belong to one store. Stores also need a relationship with orders where stores can have many orders, orders belong to one store.
Products should have the following parameters:
Number = ID
Number = Price
Text = Name
Store Relationship (one-to-many (as mentioned above))
Order Items should have the following parameters:
Number = ID
Number = Price
Number = Quantity
Number = Subtotal
Text = Name
Orders relationship (one-to-many (as outlined below)
Orders should have the following parameters:
Number = Cart Number
Number = Paid Order Number
Number = Subtotal (without tax if tax is applicable)
Number = Tax (if applicable)
Number = Total
True/False = Paid
Date/Time = Paid Date & Time
User relationship (one-to-many, where user can have many orders, an order belongs to one user)
Store Relationship (one-to-many (as mentioned above))
Order Items relationship (one-to-many where orders can have many order items, an order item belongs to one order).
When a product is “added to cart”, you create a new order item for the logged-in user’s order. You use the Order Item ID and the Product ID numbers to know if the current product is already in the cart and to update the quantities when the add to cart button is pressed again.
You’ll also need to create an order prior to the user visiting your products list screen and/or grab the user’s unpaid order prior to visiting the products list screen.
I would highly recommend checking out Adalo’s e-commerce template to see how they set that up. Alternatively, you can purchase my Point of Sale template where I pretty much do this same exact method that I’ve walked you through here. The only difference is that my template does not have multiple stores as it’s made for an individual shop. A 3rd option, you can book a mentoring session with me where I’ll walk you through the process and answer any questions you have along the way.