Skip to main content
Solved

e-Commerce and placing an order with multiple items

  • February 23, 2022
  • 1 reply
  • 11 views

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)

Best answer by Kamille_Parks11

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:

View original
Did this topic help you find an answer to your question?

1 reply

Kamille_Parks11
Forum|alt.badge.img+25

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:


Reply