tr Skip to content
Black Friday FlowMattic for life, 12 payments of $33.25 Or $399 once. Nothing added for splitting Ends in --Days --Hrs --Min --Sec See the deal

Loop Through Array Data with the FlowMattic Iterator

FlowMattic Iterator: each line item of a WooCommerce order becomes its own Google Sheets row, then the loop ends with Iterator End.

To loop through array data in FlowMattic, you use the Iterator. Point it at a list (the line items of an order, rows from a table, records returned by an API) and the steps after it run once for every item. When the loop is done, the steps after an Iterator End run once, with everything you collected along the way.

Most real data arrives in lists, while most actions handle one record at a time. The Iterator bridges the two without code. With the Wait Between Items setting added in FlowMattic 7.3.0, it also paces the loop so you stay under an API’s rate limit.

What is the Iterator?

Iterator by FlowMattic is a built-in step in the Flow Controls group, described as “Run the next steps once for every item in a list.” Its action event is Loop Through Array. Two companion steps complete the loop:

  • Iterator End (End the Iterator): marks where the loop finishes. Steps after it run once, after all items are processed.
  • Iterator Storage: collects a value from each pass, with Store as String or Store as Array, so you can use the combined result after the loop.

Together they cover the usual loop pattern: for each item, do something, keep a note of the result, then report once at the end. The Iterator sits with the other workflow logic modules in the builder.

How Loop Through Array works

  1. Add a step after the one that returns your list and choose Iterator by FlowMattic, action Loop Through Array.
  2. In Iteration Array, map the list from an earlier step with a dynamic tag, or paste a JSON array.
  3. Choose the Iteration Processing Method (Direct or Batch) and, if you need it, Wait Between Items (seconds).
  4. Add the steps that should run for each item. Map item fields from the Iterator’s output.
  5. Add an Iterator End step where the loop should stop, then the steps that should run once afterwards.
  6. Open the Test tab. The test returns only the first item, which is enough to map fields in the steps below.
FlowMattic Iterator step Configure tab showing Iteration Array, Simple Response, Iteration Processing Method, Batch Size and Wait Between Items.
An Iterator set to Loop Through Array over the order's line items, using the Direct method with a one-second wait between items.

For each pass, the Iterator gives the steps inside the loop:

  • array_item_number: the position of the item, starting at 1.
  • current_array_item: the whole item as JSON.
  • Every field of the item as its own tag, for example sku, quantity and price for an order line.

If there is no Iterator End, every step after the Iterator runs once per item, right to the end of the workflow.

Iterator settings

SettingWhat it does
Iteration Array (required)The list to loop over: a dynamic tag holding a JSON array, or a JSON array you type.
Simple Response“Retrieve the data in simple format”. On by default. When on, nested arrays inside each item are split into individual fields; when off, they stay as JSON text.
Iteration Processing MethodDirect processes all items in one go (faster). Batch processes the list in the background, a chunk at a time, for lists large enough to time out the server.
Batch SizeItems per chunk. Required when Batch is selected.
Wait Between Items (seconds)Optional pause before each item after the first, from 0 to 60 seconds, decimals allowed. Leave it empty for no wait.

Iterator Storage has its own fields. Store as String uses Create the String: on each pass, the text you build is appended to what is already stored. Store as Array uses Data Parameters, key and value pairs that become one array entry per pass; after the loop, the output is a JSON list of all entries.

Use cases

One spreadsheet row per order line

A store owner wants each product sold as its own row for stock planning, plus one Slack message per order.

WooCommerce new order → Iterator (line items) → Google Sheets Add New Row → Iterator End → Slack Send Channel Message

Import contacts without hitting a rate limit

A SaaS team syncs the day’s sign-ups to its CRM, whose API allows about one request per second. Wait Between Items set to 1 keeps the loop under that limit.

Schedule (daily) → API request (new sign-ups) → Iterator (Wait Between Items: 1) → HubSpot Create Contact

Remind every overdue record in a table

Internal ops keeps invoices in WP Tables. Each morning, every overdue row gets its own reminder email.

Schedule (daily) → WP Tables Find Multiple Records (status: overdue) → Iterator → Send Email to the row's contact

Check every client site, report once

An agency checks each client’s site and sends a single summary. Iterator Storage collects one entry per site, and the email after Iterator End includes the whole list.

Schedule (weekly) → API request (client list) → Iterator → API request (site check) → Iterator Storage (Store as Array: site, status) → Iterator End → Send Email report

Summarise a batch of reviews with AI

A product team receives reviews in batches. An AI Agent writes a one-line takeaway for each, and Store as String builds a digest for Slack.

Webhook (review batch) → Iterator → AI Agent (one-line takeaway) → Iterator Storage (Store as String) → Iterator End → Slack Send Channel Message

Load a large CSV into your email list

Marketing uploads a CSV with thousands of subscribers. The Batch method spreads the work over background requests so the import doesn’t time out.

Webhook (file URL) → CSV Parser (Parse CSV File) → Iterator (Batch, Batch Size: 50) → Mailchimp Add New Member

Act only on the items that qualify

A support team polls a ticket API and only wants alerts for urgent tickets. A Filter inside the loop skips the rest of the steps for any item that doesn’t match, and the loop moves on.

Schedule → API request (open tickets) → Iterator → Filter (Continue If: priority Exactly matches urgent) → Slack Send Channel Message

Tips and gotchas

  • Waits are capped per request. The waits in one request add up to at most 5 minutes; past that, the remaining items run without waiting, and the Iterator’s entry in Task History says so. In Direct mode, a 2-second wait therefore covers only the first 150 or so items. For long lists with a wait, use Batch: each batch runs in its own request, so the cap applies per batch.
  • Batch needs a loopback. Batch processing works by your site calling its own admin-ajax.php in the background. Hosts or security plugins that block requests from the site to itself will stall it. While batches are queued, the run shows as Waiting in Task History.
  • An empty list ends the run. If the Iteration Array is empty, the loop doesn’t start and the steps after Iterator End don’t run either. Put a Filter or Branch before the Iterator if you need a “nothing to do” message.
  • Itemize plain lists first. The Iterator works best with a list of objects. For a simple list of values, the PHP Array module can itemize it into a shape the Iterator handles cleanly.
  • Storage is per run and short-lived. Iterator Storage is cleared each time the Iterator starts and kept for one hour, so read it in the steps after Iterator End, not in a later run.
  • No Conditions tab. The Iterator, Iterator End and Iterator Storage don’t have step conditions. Use a Filter or a Branch inside the loop to decide per item.
  • Routers and Branches work inside loops. You can split each item down different paths before the Iterator End.

Related features

  • Filter: skip items inside the loop that don’t meet your conditions.
  • WP Tables: find the rows you want to loop over, then update each one.
  • Scheduler: run a loop on a timetable, such as a nightly sync.

FAQ

How do I loop through array data from a webhook?

Capture a sample request so the webhook’s fields are available, then add an Iterator and map the array field into Iteration Array. The steps after the Iterator can then use each item’s fields.

How do I run a step once after the loop finishes?

Add an Iterator End step after the steps that should repeat. Everything after Iterator End runs once, after the last item. Use Iterator Storage inside the loop if that final step needs the results.

How do I avoid API rate limits in a loop?

Set Wait Between Items. It pauses before each item after the first, up to 60 seconds, with decimals allowed, so 0.5 means at most two items a second. You don’t need a Delay step inside the loop.

Can I see each item’s steps in Task History?

Yes. The run records the Iterator’s settings (method, batch size and any wait) and the steps executed for each item, so you can trace which item caused a problem.

The Iterator is included in every FlowMattic plan, with unlimited workflows and runs on your own server, so a loop over a thousand items costs nothing extra. Try FlowMattic on a live demo site and build your first loop.

More from the blog