How to copy several items into a DB?

You can create a list of things but it is tricky indeed. Explained here: Create list of things and attach to another list of things 1 by 1

But if you want to do it in another tricky way but less technical, you can create a singlepurchasedproduct whenever an item is added to the cart. Then, when the cart is paid for, you can calculate the line totals for each singlepurchaseditem and add it to an invoice (it is doable since there is a make-changes-to-a-list-of-things action). See my example running below:

invoice

In my example, a cart item is connected to a single purchased item whenever it is added to the cart and removed whenever the cart item is removed. So, at the end, there is always one-to-one list of cart items in the single purchased items list.

Then, when cart is paid, I am simply copying the amounts set in the cart to the single purchased items and calculate the line total etc. Of course, I am doing a search, but you should create a better data relation in here to find the actual cart item.

Finally, when the invoice is generated, all happens is get the list of single purchased items and you can print or calculate the invoice total. These can be done together with the previous step:
image

And this is the data structure underneath all these:

3 Likes