Aggregate scopes (product types, vendors etc.)

ACF supports creation of custom fields for Shopify entities, that don't in themselves serve as "real" objects 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 or a specific vendor, just as you would for any other product or collection in ACF. 

This allows you to store content where it makes most sense, for example vendor information at a higher level than your individual products, making it easier to maintain your field values.

Restrictions

Custom fields for aggregate scopes 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 or vendor fields with other namespaces than the above and you cannot use these namespaces for shop-level custom fields.

Important: ACF stores the custom field values for aggregate scopes across the individual ids (product types or vendors) in a single shop-level metafield, thus putting a limit on of how much data you can store in a single field. Shopify currently has a 100,000 bytes limit for metafields

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.product_type | handleize %}
<p>{{ shop.metafields.types.care_instructions[product_type_handle] }}</p>
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us