e-Commerce and placing an order with multiple items

Hello everyone!
I need to implement order creation in e-commerce. So, I have a “Products” table and an “Orders” table. The “Orders” table has a “Selected Products” field that is linked to the “Products” table. When a user selects a product, the link is implemented and all data from the “Products” is provided in the “Orders table”.

There is such a case when the user must select the quantity for each product, and the total amount must be calculated accordingly. However, I have no idea how to bind each quantity for each product that is taken from “Products” table. Can you give any suggestions to solve this problem?

The architecture looks like this:
Table “Orders”: fields “Selected Products”: Product1, Product 2 [links]; “Total Amount”, “Quantities” (Here user needs to enter for Product1 and Product 2); “Price” (from “Products”)

Table “Products”: fields “Name”, “Quantity”, “Price”

Total amount = price[0] * quantities[0] + price[1] * quantities[1] (I need such formula)

You need a junction table. Instead of linking products directly to orders, you need a “Line Items” table that links to orders and products and contains a field for quantity. See this template for an example:

1 Like

This topic was solved and automatically closed 3 days after the last reply. New replies are no longer allowed.