Use Metafield Comparison in Low Inventory Flow

Topic summary

Goal: trigger low‑stock alerts per product using a product metafield (custom field) that stores each product’s threshold, instead of a single global number in Shopify Flow.

Key constraints (earlier in thread):

  • Flow treated metafield values as strings, preventing numeric comparisons in conditions. Liquid could format values inside an action (e.g., email body) but couldn’t control whether the email was sent.
  • A third‑party workaround (Mesa automation app) was suggested.

Clarifications:

  • Attempting to use getProducts with a comment or nonstandard syntax won’t work; that field expects an API query string (see in‑app help for correct syntax). A screenshot was shared, but the issue is about query formatting and not a viable solution for numeric comparison.

Latest update (most significant):

  • Flow now supports “Run code,” which can fetch a specific metafield and output it as a number usable in a condition. This enables comparing variant inventory to the product’s metafield threshold and gating the email action accordingly.

Status: Previously blocked, now actionable using Run code. No formal template provided, but the path to implementation is available.

Summarized with AI on January 4. AI used: gpt-5.

Since this isn’t possible currently in Flow, I thought I’d recommend our automation app mesa as a solution here. I could build you out a template for this if you were interested.