Shopify themes, liquid, logos, and UX
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 -%}
<span class="label {% if forloop.index == 1 %}label--custom{% else %}label--custom2{% endif %}">{{ product.metalfields.custom_badge }}</span>
{%- endfor -%}
{%- else -%}
{%- for tag in product.tags -%}
{%- if tag contains '__label' -%}
<span class="label label--custom{% if tag contains '__label2' %}2{% endif %}">{{ tag | split: ':' | last }}</span>
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- unless product.available -%}
<span class="label label--subdued">{{ 'collection.product.sold_out' | t }}</span>
{%- 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!
Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025