Customer Metafields empty on product-template.liquid

Highlighted
New Member
2 0 0

I Imported metafields to customers via API, I can then read them back to confirm they are there, I can use an App, Metafields Guru, to confirm they are all there as well, even add a few more test ones to confirm customers have metafields.

 

In the product template, I am trying to loop through the metafields, snippet below, and the collection is always empty, it echo's is customer, but that's it.  I have tried every possible (haha) way to reference the metafields by namespace, in quotes, [] and nothing.  It's almost like on the product-templet the metafields have not bound to the customer object.  Any ideas??

 

{% if customer %}

IS CUSTOMER <- gets here
{% for metafield in customer.metafields %}
TESTING <- never gets in here
{% endfor %}
{% endif %}

0 Likes
Highlighted
Shopify Partner
1166 32 214

@andyD513  Try this 

      {% if customer %}
        {% for metafield in customer.metafields.Namespace%}
        	{{ metafield | last}}
        {% endfor %}
      {% endif %}
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution
- Available for hiring. lixon@ecommercestudio.in
0 Likes
Highlighted
New Member
2 0 0

@Lixon_LouisThanks but already tried that and other combinations, very frustrating.

0 Likes
Highlighted
Shopify Partner
1166 32 214

@andyD513 it works if the Namespace is common. In my case the metafields were  customer.metafields.global.test1  &  customer.metafields.global.test2

{{metafields.last }}or {{metafeilds | last}} will print out the value of test1 and test2 keys

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution
- Available for hiring. lixon@ecommercestudio.in
0 Likes