Skip to content

Shopify Dude Fix

Shopify Flow: Match a SKU and Line-Item Property on the Same Item

Avoid false-positive Shopify Flow routing by checking the SKU and personalization property on the same line item.

Quick answer

To avoid false-positive routing in Shopify Flow, check the SKU and line-item property on the same order line, and check the property key and value on the same attribute.

On this page

Why it happens

One product may have the eligible SKU while another has the property. The workflow must check both facts on the same line.

Build the condition

Use Add criteria for same item on the order line items list.

  1. Open Apps → Flow and start with Order created.
  2. In a condition, check Order → lineItems → sku against the eligible SKUs.
  3. Choose Add criteria for same item on lineItems before checking that line’s customAttributes.
  4. Within customAttributes, require key = Engraving Type and a value that exists and is not empty. Keep key and value on the same attribute.
  5. Only after a qualifying match should the workflow add a routing tag or perform an action.

When the editor cannot express both nested same-item tests, use the Run code action rather than independent list conditions.

Run code: a reliable same-line check

Flow Run code takes a GraphQL-shaped input query, executes JavaScript, and returns typed output for later conditions. Set its Input to:

{ order { lineItems { sku customAttributes { key value } } } }

Set its Output schema to:

type Output { matches: Boolean! }

Then use the following code, replacing the example SKUs and property key with actual values from a test order.

export default function main(input) {
  const eligible = new Set(["PERSONAL-100", "PERSONAL-101"]);
  const matches = (input.order?.lineItems ?? []).some(line => {
    const sku = String(line.sku ?? "").trim().toUpperCase();
    return eligible.has(sku) &&
      (line.customAttributes ?? []).some(attribute =>
        attribute.key === "Engraving Type" &&
        String(attribute.value ?? "").trim().length > 0
      );
  });
  return { matches };
}

Follow Run code with a Condition that checks whether matches is true. The outer some() tests each line separately; the inner some() tests key and value within a single attribute. Whitespace-only values are rejected. Property names are exact strings, so inspect the saved order data before changing the spelling.

What the workflow should actually do

A qualifying match might add an order tag, notify a production team, or flag a fulfillment for review. An order tag such as engraving is not evidence that a specific SKU has a completed engraving property. Use tags as outputs or reporting aids, not substitutes for line-level checks. Tagging an order also does not automatically reassign its fulfillment to another warehouse or shipping app.

Common misunderstanding

AND does not automatically mean “on the same item.” Two independent “at least one” conditions joined by AND can be satisfied by two different lines. The same trap applies when checking the property key and nonempty value across separate attribute entries.

How to test this

  • Eligible SKU with nonempty Engraving Type: match.
  • Eligible SKU with missing, empty, or whitespace-only property: no match.
  • Eligible SKU on line A and engraving property on line B: no match.
  • Property key on one attribute and nonempty value on another: no match.
  • One qualifying line among several other items: match.
  • Inspect the Flow run log; test with a storefront order or Run Flow automation on an existing order.

Sources and further reading