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:使用to identify the metafield in your Shopify admin, such asColor.
  • 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 iscustom.color.
  • 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.
  • Validations(optional): the rules for the input of the values, such as character limits, or minimum and maximum values.

For example, a metafield definition for product expiration date might have the key ofproducts.expiration_date, a value ofDate, and a description ofEnter the date in the format YYYY/MM/DD. Its validations might specify that only date values between2025/07/01and2030/12/31are valid.

For more information about the parts of a metafield definition, refer to the following table or reviewthe developer documentation for Metafields.

Parts of a metafield definition
Name Description
Namespace and key

Together, the namespace and key create a unique identifier for your metafield. They're separated by a., and can only contain letters, numbers, underscores (_), and hyphens (-).

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 namespaceproductsto group the keysexpiration_dateand评级for your product metafields.

Standard definitionsuse standardized namespaces and keys, whilecustom definitionsuse automatically generated namespaces and keys that you can edit.

Value

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 toMetafield content types and values.

Description (optional) 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.
Validation (optional) 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.
Shopify准备OB欧宝娱乐APP开始销售?Try it free