Metafields are a flexible way for your app to add and store additional information about a Shoplazza resource, such as a product, a collection, and many other types.

How it works

A metafield includes the following parts:

  • Namespace: A container for a group of metafields. Grouping metafields within a namespace prevents your metafields from conflicting with other metafields with the same key name.
  • Key: The name of the metafield.
  • Type: The type of data that the metafield stores.
  • Value: The data to store in the metafield.

Examples

In the following examples, a merchant that sells clothing uses metafields to store the care instructions for each product. The online store has separate metafields for washing and drying instructions, which are grouped by the instructions namespace. Each product can have a different value for each metafield. A metafield set includes all the data for a particular metafield.

The following example shows the structure of the instructions.wash metafield:

{
  "product": {
    "metafields": {
      "namespace": "instructions",
      "key": "wash",
      "type": "single_line_text_field",
      "value": "Machine wash cold."
    }
  }
}

Metafield types

Each metafield has a type, which defines the type of information that it can store. The metafield types have built-in validation and Liquid support.

For more information about the supported types, refer to Metafield types.