Skip to main content

Metafields

There are two types of metafield we commonly use on our stores. Both have slightly different limitations and layouts. Examples of both can be found below.

Usage

Since the introduction of Shopify 2.0's Metafields and MetaObJects we now try to use these wherever possible, and only fallback to ACF where required. MetaObjects can be used to replace global ACF metafields, allowing the client to create reusable content for the site.

Naming conventions

Because of the limitations with ordering and grouping, it is even more important that they are named in a way which makes it clear when fields are related to each other by using a prefix. The prefix should directly correlate to the namespace, with the key following it.

These would again be in sentence case to match the Customiser settings.

For example; if you were setting up a tag for a product card you may have the following metafields:

Tag
{
Name: 'Tag - Title',
Key: 'tag.title'
},
{
Name: 'Tag - Text colour',
Key: 'tag.text_colour'
},
{
Name: 'Tag - Background colour',
Key: 'tag.background_colour'
}

Metafields expanded

Metafields contracted