Display company metaobject for loggued in customer

Topic summary

A B2B store owner is attempting to display a custom company metafield (custom.commercial_b2b) containing contact person names to logged-in customers on their homepage using Liquid code. Despite using what appears to be correct syntax for accessing a single-line text metafield with one value, nothing displays on the frontend.

Code attempted:

{% if customer %}
{% assign company_metaobject = customer.metafields.custom.commercial_b2b.value %}
<p>{{ company_metaobject }}</p>
{% endif %}

Key details:

  • Theme: Dawn
  • Metafield type: Single line text, one value (not list)
  • Target location: Homepage
  • The same code works correctly in a test environment

Current status: The issue remains unresolved. The helper confirmed the code structure is correct and successfully tested it elsewhere, suggesting the problem may lie in the metafield definition or store-specific configuration. Without collaborator access to inspect the actual store setup, remote troubleshooting has reached its limits. A direct call was proposed for further investigation.

Summarized with AI on November 1. AI used: claude-sonnet-4-5-20250929.

Hi !
I have a B2B website and I try, with custom Liquid, to show to loggued in customers the name of their contact in my company.

I have created a custom company text metafield (custom.commercial_b2b) in which i can, for each company, enter the name of the person they need to contact.

There is the code I tried to show this custom metafield content on the front of my store :

{% if customer %}
{% assign company_metaobject = customer.metafields.custom.commercial_b2b.value %}
<div>
<p style="font-size:20px; text-align:center;font-weight:bold" >{{ company_metaobject}}</p>
</div>

{% endif %}

Could you please help me ? I have searched in many topics but i don’t get where I’m wrong.

Thanks !

Hi @WebSO ,

Would you please confirm if you have created a metafield or a metaobject because each has a different ways to access the values?

Hi !

I’ts a metafield.

okay great,

on which page you are trying to show this value?

can you give me the collaborator access so that I can analyze the problem in more detail?

It’s on my HP.

I don’t have the authorization to give you this access unfortunately

okay no worries.

Just let me know on which page you are trying to show this metafield and which theme you are using?

I have tested your code on my own store and it is displaying the value correctly.

So there might be a problem with the definition of your metafield.

Have you defined it as a Single Line Text?

Also have you selected One Value option while creating metafield or List of Values option?

Yes and one value! I’m using Dawn theme, and i want to display it on my homepage

Hmmm, that’s weird as it should work.

Have you checked the value by creating and logging in to customer account?

What is displaying in that field?

Nothing is displayed

Hi, it seems that without getting access to your store I am unable to do anything.

if you want you can schedule a call with me where I can troubleshoot your issue