Metafields
In addition to syncing the ID verification status to the tags on the order and customer profile - Real ID also syncs metafields to the order and customer profiles on your Shopify store.
For example when an order requires ID verification, then Real ID will update the real_id.step
to in_progress
on the order. Then when the customer completes ID verification, the real_id.step
metafield will be updated to completed
.
You can use these metafields within your store's theme to conditionally show or hide elements based on the customer's verification status, or alter the customer experience entirely.
real_id.verified
Metafield
This metafield is present on both the customer and order. It is a boolean type that will only be true
if the ID check was passed or it was manually approved.
For example, you could use it to tell if the currently logged in customer is verified within a liquid template:
{% if customer %}
{% if customer.metafields.real_id.verified %}
You're verified! ✅
{% else %}
You're not verified ❌
{% endif %}
{% endif %}
real_id.step
Metafield
This metafield is present on both the customer and the order. It is a short text field that can be one of three values:
in_progress
- an ID check has not been completed yetcompleted
- the ID check has passed or been manually approvedfailed
- the ID check has failed or was manually rejected
Here's an example of displaying the customer's current ID verification status within a liquid template:
{% if customer %}
{% case customer.metafields.real_id.step %}
{% when 'in_progress' %} Please complete your ID check to continue
{% when 'failed' %} We were unable to verify your ID
{% when 'completed' %} You have passed ID verification
{% endcase %}
{% endif %}
This metafield will only be present on orders or customers that require ID verification.
If you have rules set up that only require ID verification on specific conditions, then these metafields will not be present on those orders.
Liquid Examples
Here are some examples to help with common uses of metafields.
Displaying a blur on images if the customer isn't logged in and verified
You can add a blur to all images on your site if the customer isn't logged in and verified using a condition on the real_id.verified
metafield:
// styles.css.liquid
{% unless customer.metafields.real_id.verified %}
img {
filter: blur(1.5rem);
}
{% endunless %}
You will need to use a .css.liquid
or .scss.liquid
file for this functionality. A normal CSS file will not be able to detect the currently logged in customer's metafields.
Display a call to action to verify if the customer isn't verified yet
You can conditionally show a call to action to login and verify if the customer isn't verified yet.
{% unless customer.metafields.real_id.verified %}
<div>
<h2>Verified account required</h2>
<p>
To continue with checkout, please login and verify your ID.
</p>
<p>
This process is instant and only needs to be done once.
</p>
<a href="/account/login">
<button>
Sign In
</button>
</a>
<div>
{% endunless %}
Accessing Metafields with GraphQL
In addition to accessing ID verification metafields via the Liquid within your store's theme, you can access these fields through the Shopify Admin GraphQL.
Customer ID verification metafields
Here's an example query to retrieve the current ID verification related metafields with a GraphQL query:
query getCustomerDetails($customerId: ID!) {
customer(id: $customerId) {
firstName
lastName
email
phone
id
tags
metafields(first: 5, namespace: "real_id") {
nodes {
key
value
updatedAt
}
}
}
}
Order ID verification metafields
Here's an example query to retrieve the current ID verification related metafields with a GraphQL query:
query getOrderDetails($orderId: ID!) {
order(id: $orderId) {
id
tags
metafields(first: 5, namespace: "real_id") {
nodes {
key
value
updatedAt
}
}
}
}
ID verification before before checkout
If your store is requiring ID verification before checkout or before viewing store, then the metafields on the customer will be applied after they register or after they place an order and Shopify creates their customer profile.
To use the ID verification metafields on your store's theme, we highly recommend you prompt customers to login. Without the customer logging in, your theme won't be able to access the customer's current ID verifications status through metafields.