I have been searching the forum and seem not to be able to find a solution I can follow, for what I can only imagine is a solved problem. I am hoping someone can help
When my user checks out I want to send them an email showing the list of items (the order) they have purchased and issue a sales receipt.
Where I am struggling is to include in the email the list of items in their order.
This should be
item name | Quantity | Item Price
I cannot seem to get this from bubble into a row per line item. I can output each list so
“Format as text” will allow you to iterate over each item in a list. Within the format as text function, you can define what you want to see from each item (this item’s name, this item’s price, etc.) .
The only issue with this approach will be if you’re trying to render an image for each line item, but you may be able to get around this by wrapping “this item’s img url” in bbcode or similar.
I think the challenge is that Item is a foreign key in Order, linking to Item Table, Quantity is a list in order thus it seems to call when using “Format as text” the item name but then I want to inner iterate the quantity list, but cannot seem to get it to do so
E.g.
Format as text 1
Format as test 2
Results in
Product name Quantity 1, 3 Quantity 1, 3 Product Name
What I am looking for is
Product Name Quantity 1
Product Name Quantity 3
It is the traversing two lists in unison, I cannot seem to get it to do.
So are you structuring each order with a list of items from a fixed list, then a separate list for the qty of each item sold?
If I’ve read that right, then I’d probably suggest fundamentally changing the orders to contain a “line item” datatype, within which you have the item name & qty (plus any other relevant information, price etc.). Having the qty separate makes this a fair bit harder, since there’s no way to reference the current item’s index in the formatted text, so you’d either need to have all the data available in a single “thing” (line item), or have a number field to reference on each item in the order (which seems way more convoluted to me).
Within the format as text function, I can see that you’re still referencing a workflow step, when you should be referencing the current list item. So you’d use it like so:
Order
Order ID, ChartCheckout, Items (list of Item IDs)
This seemed to be the best 3nf normalised form, however I seem unable to bring in the quantity from CartItems when building the email. Hence pulling it from the worflow
however I added a itemQuantity list to Order, to try to pull it from the workflow. In the end as a work around I created a list within Order call itemQuantity and tried to pull it from there, but not working.
Maybe my understanding of how bubble handles data is flawed
I will try your suggestion unless you think there is something I could improve in the data structure.
I think the structure looks fine, though obviously this is just at a glance. All I’d say is you need that one extra datatype in a line item.
So have the Line Item datatype as a foreign key (list) in your orders, then set your Item datatype to be a foreign key for each line item. That should give you a similar structure, but creates an instance of each line item’s use, with the associative qty, price, total price (whatever else you want).