Metafields in Flow
When building a workflow you might want to get or set metafield and metaobject data in your store.
Get metafield data
Metafield data is different than other store data because each field is custom to your shop, and it can be a different type than other data in your store. Because of this, Flow needs to do extra work in order to provide you with an easy way to access this data, which results in a different experience for you over just selecting a field in the environment such product.title
.
To access metafield data on any resource, the process is roughly the same:
- Click Add a variable in an action, or Add criteria in a condition.
- Go to the resource where the metafield is stored (such as product, customer, order).
- Choose
metafield
from the list of fields. (note: don't choosemetafields
as this provides a list of all metafields). - In the popup, select the metafield using the namespace and key, make a note of the alias name provided, and click Add.
- When the alias is added, the environment panel will reload and select the new metafield alias. From that new field, choose the variable you want to use. In some cases, this will simply be
value
. After adding a metafield to a workflow, you no longer need to add it again. You can simply reference it in subsequent steps.
Update metafield values
Flow provides actions to update metafield values:
- Update collection metafield
- Update company location metafield
- Update company metafield
- Update customer metafield
- Update order metafield
- Update product metafield
- Update product variant metafield
- Update shop metafield
Create metafield definitions
Flow also provides a way to create metafield definitions in your store. This is useful if you want to add metafields to resources that don't already have them.