Custom Product Metafield for product labels/badges on Collection Pages

How do I change my product label to say what i have assigned in the custom metafield

I have a custom single line text metafield set up as ‘custom.product_badge’ which includes ‘coming soon’ ‘staff pick’ etc.

How do I make this come up instead of sold out on collection pages?

<product-item class=“product-item {% unless product.available %}product-item–sold-out{% endunless %}” {% if reveal %}reveal{% endif %}>
{%- capture product_labels -%}
{%- if product.metafields.custom_badges != blank -%}
{%- for custom_badge in product.metafields.custom_badges.value -%}
{{ product.metalfields.custom_badge }}
{%- endfor -%}
{%- else -%}
{%- for tag in product.tags -%}
{%- if tag contains ‘__label’ -%}
{{ tag | split: ‘:’ | last }}
{%- endif -%}
{%- endfor -%}
{%- endif -%}

{%- unless product.available -%}
{{ ‘collection.product.sold_out’ | t }}
{%- endunless -%}

Hi Erin,

You’ll need to properly call the metafield via resource.metafields.namespace.key. From what I see, you are missing the namespace.

If you’d like me to fix this for you and have it working properly, I’d be happy to assist for a flat fee of $20. Feel free to reach out if you have any questions.

Good luck!