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)