How can I tag an order with a customer metafield value?

Topic summary

Goal: Tag newly created orders with a customer metafield value using Shopify Flow and Liquid.

What was tried: A Liquid loop over order.customer.metafields to find a specific namespace and key, then output the metafield value as the tag. Initial snippet had issues: invalid variable name (mf.value), missing endif, and syntax inconsistencies.

Corrections proposed: Use the loop variable consistently and include the endif. Output should reference the exact loop variable’s value (metafields_item.value). Ensure namespace and key match the intended customer metafield.

Current status: Flow runs show “succeeded” but the order tag is not appearing. A screenshot was shared indicating success status without tags.

Likely cause: A remaining typo or variable mismatch (using metafield.value instead of metafields_item.value) preventing the value from being emitted for the tag.

Key terms:

  • Metafield: Custom key-value data on customers identified by namespace and key.
  • Liquid: Shopify’s templating language used in Flow to generate dynamic values.

Outcome: No confirmed resolution yet. Action items: fix the variable name and syntax, verify namespace/key, and re-run the Flow to confirm the tag is created.

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

Hey hey, I’m trying to make a flow :

  • When a new order is created , the order to be tagged with a Customer Metafield value.

Currently trying the following ,and although on the flow app it says that it’s successful, the tag with the metafieled value is not added on the order.

I currently use :

  • {% for metafields_item in order.customer.metafields %} {if {metafields_item.namespace==“namespace” and metafields_item.key == “key” }},{ mf.value }{% endfor %}
1 Like

Hi Raym1, there are a few issues in the code snippet you shared:

  • the mf.value is invalid. “mf” should match the variable used in the rest of the liquid code to output a variable.
  • the end if statement is missing after the metafield value
  • There are some inconsistencies with the liquid syntax

So the liquid code should look like this:

{% for metafields_item in order.customer.metafields %} 
{% if metafields_item.namespace == "namespace" and metafields_item.key == "key" %}
{{metafields_item.value}}
{% endif %}
{% endfor %}

Just make sure to swap out the namespace and key to match the metafield you want to add as a tag.

Hope this helps!

1 Like

Appreciate your response Ethansz.
However, although the recent runs on the flow app say have the status: succeeded ,no tags are created on the order from the desired customer metafield value.

You have a typo…it should be {{metafields_item.value}} not {{ metafield.value}}

1 Like