Collections with metafields
Collections can have selection conditions to automatically include matching products or variants. A single collection can have a maximum of 60 total conditions, and you can specify if products or variants need to meet all conditions or any condition to be included in the collection. You can use metafield data as part of the conditions to give you more specific control of your collections.
Complete the following actions before you create a collection condition using metafields:
- Add in your metafield definitions.
- Activate collections by metafields.
- Add the values to your products or variants.
- To have category metafield conditions narrow collections to specific variants, connect the category metafield to a product option.
On this page
Benefits of using metafield data in collection conditions
Collection conditions with metafields can help you create more precise automated collections, when you need to use structured product or variant information. In comparison, tags assigned directly to products are useful when you need a simple label or grouping method. For example, you might use tags such as sale, fragile, or vip to group products for internal filtering or broad segmentation.
Metafields are useful when you need to store a specific attribute and value in a consistent format. For example, you might create a product metafield for material with the value cotton, or a variant metafield for fabric with the value linen. You can then use those metafields as automated collection conditions, such as including products that have at least one variant where the fabric is linen.
Because metafields are part of your data model, you can integrate this same data across Shopify, such as your online store. You can use metafields to be more specific in your collections. You can create metafield definitions for color, and then create a collection that only pulls in products that have the color value you want for the collection. You can create a metafield definition that is for fulfillment urgency, and then create a collection that only pulls in products that are marked with an urgent fulfillment value. Metafields provide more flexibility and structure than tags.
Considerations for using metafield data in collection conditions
Before using metafields to define conditions for collections, review the following considerations:
- The activate collections setting has a maximum of 128 definitions per product metafield definitions and variant metafield definitions.
- You can't delete a metafield definition until the collection is updated to remove the metafield definition as a condition.
- When using a metafield as a condition for including variants in a collection, the metafield must be connected to a linked variant option in order for the customer-facing collection filters and swatches to filter down to only the included variants.
Metafield definitions and supported conditions
Only certain product and variant metafield definitions are supported with specific conditions.
| Metafield definition type | Supported conditions |
|---|---|
| True or false | equals |
| Integer | equals greater than less than |
| Decimal | equals greater than less than |
| Rating | equals greater than less than |
| Single line text (one value and list of values) | equals |
Activating the collections setting
To use a metafield definition for collections, you need to activate the setting in your metafield definitions. Learn more about creating custom metafield definitions.
Steps:
Desktop
From your Shopify admin, go to Settings > Metafields and metaobjects.
Depending on the metafield definition that you want to use for collections, select either Products or Variants.
Click the metafield definition that you want to use for your collection.
In the Options section, select Collections.
Click Save.
Mobile
From the Shopify app, tap
, and then tap
Settings.
In the Store settings section, tap Metafields and metaobjects.
Depending on the metafield definition that you want to use for collections, select either Products or Variants.
Tap the metafield definition that you want to use for your collection.
In the Options section, tap Collections.
Tap Save or ✓.
Add metafield definition conditions to a collection
You can add a condition to include products or variants with a particular metafield. You can use product metafields or variant metafields. For example, you can set up a condition that selects products with the metafield definition Color and the value #FF0000.
Steps:
From your Shopify admin, go to Products > Collections.
Click a collection that you want to add products to.
In a Products source or a Variants source, click
Add condition > Metafield.
Select Color as the metafield definition.
Click the Select value field, and then select #FF0000.