Populate a variant metafield with the price of a product at the point the product is created

Topic summary

Goal: auto-populate a variant metafield with the product’s price when a product is created in Shopify Flow.

  • Initial approach used “Get product variant data” with a GraphQL query, which returned no results. That action expects Shopify search syntax (e.g., id filter using legacyResourceId), not GraphQL.

  • Guidance: you can access variants directly via product.variants without an extra query. Use Log output to debug values before updating metafields.

  • Blocker: the “Update product variant metafield” action lacked a Money type. The team added Money to the type dropdown, enabling proper updates.

  • Formatting: Flow’s Liquid doesn’t include money filters; the Money metafield expects a single JSON object with amount and currency_code. Output only one variant’s value (e.g., first/default) and ensure the correct namespace/key.

  • Important nuance: the “Get product variant data” action may not return default variants for single-variant products. Removing that action and iterating product.variants avoids mismatches.

Outcome: switching the For each loop to product.variants and using the new Money type successfully updates the variant metafield. Issue resolved; no open questions.

Summarized with AI on December 27. AI used: gpt-5.

Yeah, but like I said earlier in the thread, you already have access to the variants on that product via the product.variants field. You don’t need a separate action to get the variants. And in fact as you discovered earlier it seems like Default variants (that’s what they are called when there is only one) may actually not be included in that query even if you used it.

I would switch that For each loop to use product.variants, which should prove that you don’t need that Get product variant data action at all. So then delete it and you should be good.