Access field definitions
For each of the scopes, ACF offers custom fields for, selected properties from the custom fields definitions are surfaced to a special metafield for you to use in your theme with Liquid.
You can query the defined labels, the instructions etc. or show your custom fields on the storefront in the same order as defined in ACF.
If any custom fields have been created for the scope, the following metafields are available:
shop.metafields.acf_settings.product
shop.metafields.acf_settings.variant
shop.metafields.acf_settings.collection
shop.metafields.acf_settings.page
shop.metafields.acf_settings.blog
shop.metafields.acf_settings.article
shop.metafields.acf_settings.order
shop.metafields.acf_settings.customer
shop.metafields.acf_settings.shop
shop.metafields.acf_settings.product_type
shop.metafields.acf_settings.vendor
shop.metafields.acf_settings.location
shop.metafields.acf_settings.global
Each of these metafields contains a fields array containing the defined fields - excluding any sections.
Each element in the fields array has the following properties:
name
The name defined for the custom field. This is used as the key property in the metafields created for each value.
namespace
The namespace defined for the custom field. This is used as the namespace property in the metafields created for each value.
type
The type of field (text, checkbox etc.)
label
The label defined for the custom field, which is also used in the ACF editor.
instructions
These are the same instructions as shown in the ACF editor (with any Markdown translated into HTML). When using these on the storefront, take care that they are not authored for internal use.
repeatable
A boolean true if the field is defined as repeatable.
value
Depends on the type of field. E.g. for a Media field, the value will be a pipe-separated list of MIME types, or for a Selection field a pipe-separated list of options.
allow_multiple
A boolean true if the field allows for multiple selections.
section
If this field belongs to a section, you will find an id property for that section as well as a label property with the section's label. The id property is a unique internal id, that allows you to logically discern which fields belong to different sections.
Showing the label for the field "size" before the field value:
{% assign field = shop.metafields.acf_settings.product.fields | where: "name", "size" | first %}
<p>{{ field.label }}: {{ product.metafields.accentuate.size }}</p>
Listing custom fields in the same order as defined in ACF:
{% for field in shop.metafields.acf_settings.product.fields %}
{% assign field_value = product.metafields[field.namespace][field.name] %}
<p>{{ field.label }}: {{ field_value }}</p>
{% endfor %}
Listing custom fields with section headers:
{% for field in shop.metafields.acf_settings.product.fields %}
{% assign field_section = field.section %}
{% assign field_value = product.metafields[field.namespace][field.name] %}
{% if field_section.id != current_section.id %}
<h3>{{ field_section.label }}</h3>
{% endif %}
<p>{{ field.label }}: {{ field_value }}</p>
{% assign current_section = field_section %}
{% endfor %}
Getting the entry for a specific field:
{‰ assign my_field_def = shop.metafields.acf_settings.product.fields | where: "namespace", "accentuate" | where: "name", "my_custom_field" | first %}
{% if my_field_def.repeatable %}
<p>This field is defined as repeatable</p>
{% endif %}