Accentuate Custom Fields
  • Welcome!
  • Introduction
    • Getting started with ACF
    • Field scopes
    • How to show fields in your storefront
  • Dashboard
    • Reference Manager
      • Creating a new reference within Reference Manager
    • Filter & Group
      • Filter editor
      • Filter usage
    • Activity log
    • App settings
  • Field Definitions
    • Fields & Sections
    • Deciding on a field type
    • ACF Field types
      • Text
      • Markdown text
      • HTML
      • Checkbox
      • Selection
      • Tags
      • Number
      • Date
      • Color
      • Media v1 (legacy)
      • Media v2
      • Custom Object (JSON)
      • Multi-language Text
      • Reference fields
      • References to Global fields
    • Shopify Field types
      • Shopify » Single line text
      • Shopify » Multi-line text
      • Shopify » Boolean
      • Shopify » Color
      • Shopify » Custom objects (JSON)
      • Shopify » URL
      • Shopify » Date
      • Shopify » Date and Time
      • Shopify » Integer
      • Shopify » Decimal
      • Shopify » Weight
      • Shopify » Volume
      • Shopify » Dimensions
      • Shopify » Reference fields
    • Automatic tagging
    • Large sets
    • Field contexts
    • Field context filters
    • Copy and paste fields
    • Change field name and type
    • Import existing fields
    • Linking multiple stores
  • The Editor
    • Using the editor
    • Promote fields to sidebar
    • Layouts
    • Hide from search
    • Repeatable fields
    • Version control
    • Update value on order creation
  • Bulk Import & Export
    • Export custom field values
    • Import custom field values
    • Metaobject export / import
  • METAOBJECTS
    • What are Metaobjects?
    • Metaobject Definitions
    • Metaobject instances / values
    • Displaying Metaobjects on your storefront
    • Metaobject export / import
  • THEME EXTENSIONS
    • SEO keywords
    • Sticky promo bar
    • Products promotion
  • Liquid Guides
    • Learning Liquid
    • Resize & crop images
    • Check for empty values
    • Access field definitions
    • Order notifications
    • Allow customers to change their field values
  • OTHER
    • Webhooks
    • API
      • Access to custom fields
      • Endpoints
  • Help
    • FAQ
      • Why are one of my products no longer showing in my reference field?
      • I have multiple products/variants with the same name
      • How do I make changes to my field values in bulk?
      • I added a new field definition but it is not showing in my storefront
      • How do I copy my field setup to another store?
      • My fields are still showing after I have deleted their field definition
      • Why are none of my fields showing in the editor?
      • My newly created object in Shopify is not available in ACF
      • Reference lists are empty?
      • Why am I seeing a "value cannot exceed 100,000 characters" error when saving?
      • Why can't I name my field "first", "last" or "size"?
    • Need help?
  • Product
    • Changelog
    • Feedback & Suggestions
Powered by GitBook
On this page
  • Global fields
  • Aggregate scopes
  • Accessing Metafields for types, vendors, and locations
  • Examples
  1. Introduction

Field scopes

Throughout our help articles, we use examples showcasing Metafields for the product scope, i.e. custom fields for products. This is done to maintain consistency between the different code snippets. Please know that every example, that uses the product scope can just as well use any of the other 8 scopes available:

  • variant (product.variants)

  • collection

  • page

  • blog

  • article

  • order

  • customer

  • shop

so this example use of a product Metafield:

{{ product.metafields.accentuate.my_custom_field }}

could just as well be written as:

{{ page.metafields.accentuate.my_custom_field }}

or:

{{ collection.metafields.accentuate.my_custom_field }}

depending on which scope "my_custom_field" was created for using ACF and the context of its use within the theme.

Global fields

Global fields in ACF work similarly to shop fields and the two can be used interchangeably. One crucial difference is that global fields can be referenced from field definitions belonging to other scopes such as products, collections, pages, etc. using a "Reference fields: Globals" type. This allows you to use global fields as puzzle pieces for building your field definitions for a specific scope, making it a breeze to maintain cross-site content of any type. You define and edit global fields as you would for any other scope in ACF. This allows you to store content globally available (within your shop, that is)

Custom fields for the global scope are saved as shop-level Metafields and have their namespace locked to globals. You cannot create global fields with another namespace and you cannot use the globals namespace for shop-level custom fields.

Aggregate scopes

ACF supports the creation of custom fields for Shopify-specific entities, that don't in themselves serve as scopes in Shopify and thus cannot be directly used as a target for metafields. These entities or "aggregate scopes" are:

  • product types

  • vendors

  • locations

For each of these scopes, you can define custom fields as usual and edit the values for each "instance" ie. a particular product type, a specific vendor or a location, just as you would for a product or a collection in ACF. This allows you to store content where it makes the most sense, for example, vendor information at a higher level than your individual products, making it easier to maintain your field values. Custom fields for aggregate scopes are stored with the "shop" scope in Shopify and have their namespaces locked to a specific value depending on the scope:

  • types is a reserved namespace for product type fields

  • vendors is a reserved namespace for vendor fields

  • locations is a reserved namespace for location fields

You cannot create product type, vendor or location fields with other namespaces than the above and you cannot use these namespaces for other shop-level custom fields.

Accessing Metafields for types, vendors, and locations

To access a custom field value for an individual product type, use this construct:

shop.metafields.types.my_field_name['cars'] 

Similarly for vendors:

shop.metafields.vendors.my_field_name['microsoft']

Note: the value used as the last parameter for types and vendors must be a handleized value. These shop-level metafield constructs work in a similar way as Liquid's global objects "all_products", "collections" etc.

Access to Metafields for locations follows the same general principle but uses Shopify's internal id numbers for its location objects. You don't have direct access to your shop's locations from Liquid, but you can copy a specific location's id from your shop's admin interface and use it to access the location's custom field:

shop.metafields.locations.my_field_name[1234567890]  

Examples

Showing the vendor's logo (stored in a Media v2 field) when viewing a specific product:

{% assign vendor_handle = product.vendor | handleize %}
{% assign logo = shop.metafields.vendors.logo[vendor_handle] | first %} 

<img src="{{ logo.src }}" alt="{{ logo.alt }}"/>

Showing a product's type's care instructions when viewing a specific product:

{% assign product_type_handle = product.type | handleize %}

<p>{{ shop.metafields.types.care_instructions[product_type_handle] }}</p>
PreviousGetting started with ACFNextHow to show fields in your storefront

Last updated 10 months ago