Showing Customer Metafields on Customer Account Page

Showing Customer Metafields on Customer Account Page

niki92bgd
Shopify Partner
27 0 4

Hi just wondering if anyone can help me with customer metafields. 

I have VIP customers that I want to show specific messaging to on the their classic account page. So far I have created a custom metafield definition (ensuring that i selected read storefront) 

I tried this on a test customer account but I am stuck on how to get the metafield information to show to them on their account page. 

Please help!

Replies 3 (3)

NomtechSolution
Astronaut
1245 113 155
  1. In the theme editor, locate the template file responsible for rendering the customer account page. This file is typically named customers/account.liquid or similar.

  2. Open the customers/account.liquid file and find the section where you want to display the custom messaging for VIP customers.

  3. Within that section, you'll need to add code to fetch and display the custom metafield information for the logged-in customer.

    Here's an example of how you can retrieve and display a specific metafield (assuming you have a metafield named "vip_status"):

 

 

{% if customer.metafields.namespace.vip_status %}
  <p>{{ customer.metafields.namespace.vip_status }}</p>
{% endif %}

 

 

niki92bgd
Shopify Partner
27 0 4

Thanks for that but I did get it to work, however how do I get the meta field to show to URL?

niki92bgd_0-1686851856578.png

niki92bgd_1-1686852197072.pngniki92bgd_2-1686852215215.png

 

spiffSpaceman
Shopify Partner
2 0 0

In order to display metafield (or metaobject values), sometimes you have to assign them as a variable first.

{% assign entries = customer.metafields.custom.entries.value %}
<p>Total Entries: {{ entries }}</p>