A user needs to dynamically add products to orders based on product variant metafields to create “pseudo bundles” for preorders. Their preorder app tags items with a “Pre-order” tag, and each variant contains a metafield referencing an array of products that should be bundled together.
Current Issue:
Flow workflow is generating a transient error: “Variable $variantId of type ID! was provided invalid value” with “Invalid global id”
Screenshots of the workflow and error were shared
Proposed Solution:
Another user suggests this workaround (since Flow doesn’t support nested looping):
Trigger: Order created
Run code to extract list of SKUs from line items/variant metafields
Get product variant data using that SKU list
For each variant, add line item to order
Status: The discussion remains open with a potential technical solution proposed but not yet confirmed as working.
Summarized with AI on November 4.
AI used: claude-sonnet-4-5-20250929.
I need to dynamically add a product to an order based on a product variant metafield.
How would you do this?
Since bundles are limited in the use of preorders, I want to set up a way to do bundle preorders with flow and a preorder app.
My Preorder app tag’s all preorders with the Pre-order tag.
For the bundle I am making a “pseudo bundle” with a custom product, where every product variant have a metafield. That reference to a array of products.
How would I get flow to change add the product referenced in the metafield?
I’m currently getting this error (see also picture below):
Retrying:> > Ran into transient error: [{“message”=>“Variable $variantId of type ID! was provided invalid value”, “locations”=>[{“line”=>3, “column”=>3}], “extensions”=>{“value”=>“”, “problems”=>[{“path”=>, “explanation”=>“Invalid global id ‘’”, “message”=>“Invalid global id ‘’”}]}}]
If you have multiple variants per order than can be part of bundles, this might not be possible now because you would need to loop over both line items and the variant metafields and Flow does not yet allow nested looping.
To get around that, this might work:
Order created
Your existing conditions
Run code (to get a list of skus that are stored in the lineItems / variant / metafields )
Get product variant data (using that list of skus to get all the variants to add)
Your Flow error occurs because the metafield returns an empty string instead of a valid variant ID. To fix: add a Condition action after “Get metafield value” to check if the metafield isn’t empty before proceeding to “Add line item”. Also ensure your metafield is configured as type Product variant (not plain text) in Settings → Custom data → Variants. See Shopify Flow reference.
Trade-off: Flow struggles with complex metafield structures like lists of product references, requiring multiple conditions to handle arrays.
A simpler approach for pseudo-bundles is Smart Collections with tags. Tag products needing pre-order behavior (e.g., “preorder”), create a Smart Collection from that tag, then apply pre-order rules to the collection in an app like K1 PreOrder (I’m the founder). Tagged products automatically inherit pre-order behavior - custom messages, button replacement, and scheduling - without manual Flow setup. Here’s the K1 PreOrder listing if relevant.