0
votes

I'm been trying to find a way to do this but haven't had any luck.

I'm using Metafields to store information by customer id. As a result, in order to extract the information for each customer I would like to be able to pull it using something like

{% if shop.metafields.{customer.id} %} 

Is this an acceptable way to access my metafield with the key that is equal to the value of the customer.id when the customer is signed in?

Thanks a lot!

1

1 Answers

2
votes

If you want to display a metafield that belongs to the logged in customer then you can do that like this:

{% if customer %}
    {{ customer.metafields.inventory.warehouse }}
{% endif %}

Where inventory is the metafield namespace and warehouse is the metafield key. You can find more examples of the syntax here: https://help.shopify.com/themes/liquid/objects/metafield