Metafields in Shopify Flow
Metafields are custom fields that you can use to add extra information to your products, customers, orders, and other objects in your store. Metafields can be used to store information that isn't included in the default fields of an object. For example, you can use metafields to store information about a product's manufacturer, a customer's birthday, or an order's delivery date.
When building a workflow, you might want to get or set metafield and metaobject data in your store.
Get metafield data in a workflow
Metafield data is different than other store data, or even other fields that require arguments, 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 make this data easy to access. This results in a different experience for you than simply selecting a field in the environment, such as product.title.
Steps:
- In a Shopify Flow workflow, click Add a variable in an action or condition.
- Select the resource where the metafield is stored, such as
product,customer, ororder. - Choose
metafieldfrom the list of fields to create a variable. Don't choosemetafields(plural), as this provides a list of all metafields. - In the Create variable dialog, do the following steps:
- In the Metafield menu, select the metafield from the list of structured metafields, or click Use an unstructured metafield to use the namespace and key for an unstructured metafield.
- Make a note of the Variable name provided.
- Click Add to refresh the variable selection panel.
- Choose the metafield variable that you want to use. In some cases, this will simply be
value.
After adding a metafield to a workflow, the metafield remains available as a variable option and you can quickly reference it in subsequent steps. When choosing to Add a variable, it displays nested beneath the relevant metafield option in the list of fields.
Update metafield values
Flow provides the following 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
You can create metafield definitions in workflows by using the Create metafield definition action. This is useful when you want to add metafields to resources that don't already have them.