A practical field guide from Automation Ace.
How to Handle Line Items and Arrays in Zapier Zaps
Line items are Zapier's representation of array data — multiple values of the same type returned from a single trigger event. A WooCommerce order has multiple products. A Google Sheets row lookup might return multiple matches. An Airtable record might have multiple linked records. Zapier surfaces these as line items: a set of parallel fields, one per item, that appear in the trigger output. Understanding how line items work — and when to loop vs. process them in bulk — is foundational to building reliable multi-item Zaps.
What Line Items Look Like in Zapier
When a trigger returns an array, Zapier flattens it into parallel fields using a numbered or indexed naming convention. For an order with three products, the trigger output might look like:
Line Items Name 1: Widget ALine Items Name 2: Widget BLine Items Name 3: Widget CLine Items Price 1: 19.99Line Items Price 2: 9.99Line Items Price 3: 34.99Line Items Quantity 1: 2- ...
The number at the end of each field name is the item index. Zapier creates one set of numbered fields per property, per item in the array. The test data shows all items; a real run might have a different count. All these numbered fields are accessible in downstream step field mapping.
The Core Challenge: Dynamic Item Counts
The fundamental difficulty with line items is that the count is dynamic. Your test order might have 3 items; a live order might have 1 or 15. If you hardcode a mapping for "Line Items Name 1", "Line Items Name 2", "Line Items Name 3", a 1-item order drops items 2 and 3 silently, and a 15-item order loses items 4–15 entirely.
This is why processing line items almost always requires either:
- Looping by Zapier — to process each item one at a time through the same steps, regardless of count
- A Code step — to process the full array programmatically in a single step
Option A: Looping by Zapier
Looping by Zapier is a native Zapier action that takes an array (line items) as input and runs a set of subsequent Zap steps once per item. Each iteration receives the current item's values as individual fields.
Setting Up a Loop
- Add a Looping by Zapier step after your trigger
- In the loop's setup, map the line item fields to the loop's input — each property (Name, Price, Quantity) maps to a separate loop input field
- The steps inside the loop run once per item. Reference the current item's values using the loop's output fields (e.g.,
Loop Name,Loop Price) - Add a Looping by Zapier — End Loop step to close the loop
Use Looping when you need to perform an action for each item individually — create a record per product, send an email per recipient, update a row per order line. See looping and aggregating line items in Zapier for a full loop setup guide.
Option B: Code Step for Bulk Processing
When you don't need to perform a discrete action per item — you just need to compute something across all items — a Code step is more efficient than a loop. The line item fields arrive in inputData as a comma-separated string when you pass them in bulk:
// Pass "Line Items Name" (all values) as inputData.names
// Pass "Line Items Price" (all values) as inputData.prices
// Pass "Line Items Quantity" (all values) as inputData.quantities
const names = inputData.names.split(',').map(s => s.trim()).filter(Boolean);
const prices = inputData.prices.split(',').map(s => parseFloat(s.trim()) || 0);
const quantities = inputData.quantities.split(',').map(s => parseInt(s.trim(), 10) || 0);
const lineTotal = prices.reduce((sum, price, i) => sum + price * (quantities[i] || 1), 0);
const itemCount = names.length;
const summary = names.join(', ');
output = {
item_count: String(itemCount),
line_total: lineTotal.toFixed(2),
summary
};
In the Code step's input fields, set names to the "Line Items Name" field from the trigger — Zapier automatically joins all the numbered values into a comma-separated string when you pick a line item field as the source.
Passing Line Items to Downstream Steps
When mapping line item fields to an action step — like adding rows to a spreadsheet or sending them in an email — Zapier lets you map line item arrays directly in some actions. For apps that support multi-row input natively (like Google Sheets "Create Multiple Spreadsheet Rows"), you can map the entire line item array. For apps that expect a single record per action, you need a loop.
To include all item values in a single text field (e.g., an email body or a note), concatenate them in a Code step or use a Formatter step:
// Build a formatted line item list for an email body
const names = inputData.names.split(',').map(s => s.trim()).filter(Boolean);
const prices = inputData.prices.split(',').map(s => s.trim());
const quantities = inputData.quantities.split(',').map(s => s.trim());
const lines = names.map((name, i) => `${name} × ${quantities[i] || '1'} @ $${prices[i] || '0'}`);
output = {
line_items_text: lines.join('\n'),
line_items_html: `${lines.map(l => `- ${l}
`).join('')}
`
};
Common Line Item Sources in Zapier
Apps that commonly produce line items in Zapier triggers:
- Shopify / WooCommerce — order line items (product name, SKU, quantity, price, variant)
- Stripe — invoice line items, subscription items
- QuickBooks / Xero — invoice line items
- Google Sheets — multiple matching rows from a lookup
- Airtable — linked record fields (each linked record is a line item)
- HubSpot — deal line items
- Typeform / Jotform — multi-select or repeat field answers
Line Item Count Limit
Zapier's Looping by Zapier action has a limit on the number of iterations per Zap run (typically 500 items, though this varies by plan). For bulk data processing beyond that limit, use a Code step for in-step computation or consider an external approach via the API.
Line items in Zapier are array data flattened into numbered parallel fields. The right approach depends on what you need to do: loop when each item needs its own downstream action; use a Code step when you're computing across all items at once. Either way, design for a dynamic count — don't hardcode to the number of items in your test data.
For a complete guide to setting up loops and aggregating results after the loop ends, see looping and aggregating line items in Zapier. For JavaScript array operations on the extracted data, see JavaScript array methods in Zapier Code steps. For help designing a multi-item workflow, talk to Automation Ace.
Disclaimer: This article may include links to apps, products, or services. Some links may be affiliate links, which means Automation Ace may earn a commission at no extra cost to you.