> ## Content Index
> Fetch the complete content index at: https://piotrkrzyzek.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Shopify + Zapier: How to Itemize Order Line Item Properties
- URL: https://piotrkrzyzek.com/shopify-zapier-how-to-itemize-order-line-item-properties/
- Published: 2024-03-08T20:25:22.000Z
- Updated: 2026-11-04T17:14:11.000Z
- Description: Turn Shopify order line item properties into a clean key-value object in a Zapier Code step.
- Author: Peter Krzyzek
- Tags: Technology

Zapier does not handle Shopify's order line item properties well. It gives you three fields to choose from:

- `Line Item Property Names`
- `Line Item Property Values`
- `Line Item Properties`

All three are plain text (string) fields. Merging the names (keys) with the values sounds easy, but Zapier's built-in tools **don't** handle it. The sticking point is splitting comma-delimited text when a value has a comma in it, which customer-entered values often do.

We tried Zapier's Utilities steps with many combinations of options, and none of them gave us a clean key-value object back.

## Solution

So we do it ourselves with a Code by Zapier step, with JavaScript selected as the language.

In the step's input data, add a variable (we called ours `rawData`) and map it to the raw **Line Item Properties** field. That field shows up as empty in the picker, but it does carry the data:

Then paste this into the code box:

```js
const properties = {};

// Each property arrives as a "Name: ..." line and a "Value: ..." line,
// with a blank line between properties.
const items = (inputData.rawData || '').trim().split(/\n\s*\n/);

items.forEach(function (item) {
  const lines = item.split(/\n/);
  const name = lines[0].replace(/^Name:\s*/, '').trim();
  const value = lines.slice(1).join('\n').replace(/^Value:\s*/, '').trim();
  if (name) {
    properties[name] = value;
  }
});

output = properties;
```

The step returns one field per property, named after the property, so later steps can map each value directly.

## How the code works

Zapier hands you the line item properties as one block of text, one "Name" line and one "Value" line per property, with a blank line between properties:

```txt
Name: Engraving text
Value: Love: always, forever

Name: Gift wrap
Value: Yes
```

```js
const properties = {};
```

First, we create an empty object. An object lets us use named keys, where a regular array would only give us numbered positions.

```js
const items = (inputData.rawData || '').trim().split(/\n\s*\n/);
```

Next, we take the raw text and split it on **blank lines**, so each piece holds one name and value pair. The `|| ''` keeps the step from failing on an order with no properties.

```js
const lines = item.split(/\n/);
const name = lines[0].replace(/^Name:\s*/, '').trim();
const value = lines.slice(1).join('\n').replace(/^Value:\s*/, '').trim();
```

For each pair, we split it into lines. The first line is the name and the rest is the value. We strip the leading "Name: " and "Value: " labels instead of splitting on the colon, so a value like "Love: always, forever" comes through whole. If a customer typed a line break into a field, the extra lines stay in the value too.

```js
if (name) {
  properties[name] = value;
}

output = properties;
```

Finally, we add each pair to the object by name and return it. With the example above, the step outputs `Engraving text` \= "Love: always, forever" and `Gift wrap` \= "Yes", ready to use in any later step of your Zap.