We need each order to arrive in our downstream system already carrying some per-line-item data that we store as variant metafields. It has to work for every order origin: online store/headless checkout, draft orders, orders created via the Admin API, and subscription renewal orders created by Skio. We’d rather not query Shopify again per line when the order arrives.
Since LineItem doesn’t support metafields and line item properties can’t be set after creation (see Metafields on line items? ), we went with this, and it works on a dev store:
- Flow, trigger Order created.
- A metafield alias created on order.lineItems.variant (unstructured, set up in a Log output step).
- Run code with input { order { lineItems { id variant { myAlias { value } } } } }, which builds a JSON object keyed by line item id.
- Update order metafield writes it as one json order metafield.
- Our app subscribes to orders/updated with metafieldNamespaces, and the update that follows the Flow write carries the metafield.
Questions:
- Is this the simplest supported approach, or is there a more direct way to get variant-level data onto a new order (or into its webhook payload) for all order origins?
- Is aliasing a metafield on a nested list element (lineItems.variant) officially supported in Run code, or does it just happen to work?
- What delivery guarantees does Flow give for Order created? Is it guaranteed to run for every order, and does it retry? We want to know whether we need our own reconciliation for orders that never get the metafield.
- Does Order created fire for subscription renewal orders created by a third-party subscription app like Skio (via subscription billing attempts)? Is there anything about those orders that would stop the Run code input from resolving the variant metafields?