Parts of a metafield definition
Metafield definitions specify which part of your store a metafield applies to and what values the metafield can have. Make sure that you understand the parts of a metafield definition before doing the following tasks:
Metafield definitions have the following parts:
Name: used to identify the metafield in your Shopify admin, such as
Namespace and key: the unique identifier for your metafield. You can use a namespace to group similar metafields together, but each namespace and key must be unique. An example is
- Description (optional): allows you to include descriptive information, such as what values to enter for the metafield.
- Type: the type of data that the metafield stores, such as text, file, or URL.
- Categories (on standard product metafield definitions only): The standard product categories that the standard product metafield is associated with.
- Validations (optional): the rules for the input of the values, such as character limits, or minimum and maximum values.
Options: where the metafield is available to use.
- Access: You can give the metafield access to Storefronts. This means that the metafield can be connected in your theme using dynamic sources. Learn more about access.
- Features: Use as filter in admin allows you to use the metafield to filter product searches in the Shopify admin. Learn more about filtering your products. Use in automated collections allows you to use the metafield to create an automated collection. Learn more about automated collections by metafield.
For example, a metafield definition for product expiration date might have the key of
products.expiration_date, a value of Date, and a description of Enter the date in the format YYYY/MM/DD. Its validations might specify that only date values between
2030/12/31 are valid.
For more information about the parts of a metafield definition, refer to the following table or review the developer documentation for Metafields.
|Namespace and key
Together, the namespace and key create a unique identifier for your metafield. They're separated by a
You can use a namespace to group similar metafields together, but each namespace and key combination must be unique. For example, you can use the namespace products to group the keys expiration_date and rating for your product metafields.
The type and format of information that's contained in your metafield. For example, plain text, URL, or integer.
Metafields can only accept the supported values for their content type. For more information about supported values for common types of metafields, refer to Metafield content types and values.
|A description of the metafield to help you input the correct values. The description is displayed on the Shopify admin page where you add values for your metafield.
|A setting that you can configure to limit the values that your metafield can contain. You can set minimum and maximum values, or use regular expressions to control the range of accepted values for your metafield.