Overview

Customer Fields stores custom data in two places; the app's database and Shopify’s Metafields. 

When a customer record is saved, and the data being saved contains values for custom data columns, then the app will store metafield data on the Customer resource/object in Shopify. The app's metafields are designed to use customer_fields as the namespace, and data as the key. This metafield data is accessible via the Shopify API, or on the front-end using Liquid.

The latest version of Customer Fields saves all of the metafield data in a single JSON string. The value of the string contains the app's data column keys and respective data column values. Please note that metafields are only used for custom fields; the data for standard fields is saved to the normal places within Shopify.

Liquid output

By editing the store's theme code or Shopify's email notification templates, you can display custom data collected by Customer Fields.

Syntax

To display custom data on the storefront or in email notifications, you will need to use the following syntax:

{{ customer.metafields.customer_fields.data["DATA COLUMN KEY"] }}

Note: You'll need to replace DATA COLUMN KEY with the actual data column key you wish to use

Liquid-friendly data types

Since each data column in Customer Fields has its own specific 'type', you can apply data-specific filters to format the data, or even scope out certain data attributes.

Here are several different examples of how to display the app's metafields data:

Specific examples

1) Display value for a text data column with the key of 'pet_name':

Your pet's name: {{ customer.metafields.customer_fields.data["pet_name"] }}

<!-- Outputs:
Your pet's name: Franklin
-->

2) Display value for a date data column using a Liquid date filter to control the format:

Your Birthday: {{ customer.metafields.customer_fields.data["birthday"] | date: "%b %d, %Y" }}

<!-- Outputs:
Your Birthday: February 6, 1945
-->

3) Display value for file data column using the URL attribute to embed an image:

Profile pic: <img src="{{ customer.metafields.customer_fields.data["profile_pic"].url }}" style="max-width: 150px;">

<!-- Outputs:
Profile pic: (image with 150px max width)
-->

4) Display values for a group list data column using a for loop to output certain data attributes in the array:

{% for pet in customer.metafields.customer_fields.data.pets %}
Pet name: {{ pet.name }}
Pet weight: {{ pet.weight }}
{% endfor %}

<!-- Outputs:
Franklin
30 lbs
Winston
2 lbs
--->

5) (Advanced) Display values for a group list column using a variable, multiple filters, iteration, and some logic:

{% assign pets = customer.metafields.customer_fields.data.pets %}
<h4>Your Pets ({{ pets | size }} total)</h4>
{% for pet in pets %}
<ul>
<li>{{ pet.name | capitalize }} ({{ pet.type | downcase }}), {{ pet.energy_level | downcase }}></li>
{% if pet.birthday != nil %}<li> Born: {{ pet.birthday | date: "%b %d, %Y" }}</li>{% endif %}
<br>
</ul>
{% endfor %}

<!-- Outputs:
Your Pets (2 total)

Franklin (dog), lazy
Born: October 10th, 2015

Winston (hamster), active
--->

Looking for more technical details? 🤓

Learn more about the app's metafields using our Developer Documentation.

Did this answer your question?