Forum Academy Marketplace Showcase Pricing Features

How to iterate through a list?

Hi,

I’m trying to figure out how to iterate through a list of things. I have a data type called “Items”, which hold the product name (of type = Product, which is another data type) and product qty (of type = number) while the user is still shopping and adding or removing items to their cart. The “Items” data type is kind of an interim table to hold what the user is adding to their cart, but not considered an order just yet (because they could remove items at the checkout stage).

Once the user clicks ‘Place order’, I’d like to iterate through each of the ‘items’ in their cart and create a thing for each item in my Orders table. I can’t seem to figure out how to iterate through a list. Any help appreciated.

An overview of my data types are as follows:

Cart

  • Items (list of Items)

Item

  • Product name (type = product)
  • Qty (type = number)

Product

  • Name (type = text)
  • SKU (type = text)
    …many more fields

Order

  • Product (type = product)
  • Qty (type = number)
  • Customer (type = user)
    …many more fields

Thank you.

Option A)
Workflow > General > Do Every 5 Seconds (adjust interval to your need).

Option B)
Workflow > Custom Events > Schedule API Workflow on a list.

Option C)
Drop the loop. Create an Order Header table and a Order Lines table. Create a “Order Header” field in the Order Lines table.

When added to cart, add an order line. And when the order is submitted you change the status of the Order Header from “In cart” to “Completed” or something like that.

Probably many more options to go with.