ctyler's avatar

How to record product orders

Hello all, I have a generalized question on an eCommerce site and the recording of orders/invoices.

So if you have a list of products on your site that has a name, price, etc. When someone purchases you would create an order. As part of that order you would list the product with the name, price etc. The issue that I am curious about is how the order/invoice is recorded. So you really cant list the name/price directly from the database. Wouldn't you have to copy this data to another table? Otherwise if you simply connect to the ID of the product from the order you will get the current price in the database. What if the name and/or price changes after the order is placed?

Do you have an orders and order_item tables that you copy to? Do you use an order table with a json field to record item names, prices etc. I am curious how you handle this issue and what you would consider best practice.

This effects a lot of my projects. I am currently working on an education site that generates certificates. The certificate has a course name/credit hours etc. The certificate should list these items from when the course was taken. You probably do not want it updated with the current name/price just in case it changes.

Any help, advice, and/ or suggestions would be very much appreciated.

0 likes
5 replies
sr57's avatar

You can have orders and invoices tables that record a uid and a link(s) to the pdf file(s) that was send to the customer. If you want to do some stats and don't manage an inventory, you have also to record in the orders tables the characteristics you want to stat (color options, ...)

ctyler's avatar

Hi sr57, My question is how you do that in the orders table. Would you use just a single order table, or orders and orders_items tables, then copy the product details to the order_items table?

sr57's avatar

It"s in my previous answer, if you do not need stats, you do not need orders_items table.

ctyler's avatar

So lets say I do want stats. My question is the best practice on recording " record in the orders tables the characteristics you want to stat (color options, ...)." How would you do that. Json column in the order table. A separate table with order items.

sr57's avatar

A separate table with order items that you want to stat.

Please or to participate in this conversation.