Happening Now! Exclusive AMA: Improving your Return Management with Shopify Experts | Post your questions to be answered by our team!

Custom Product Metafield for product labels/badges on Collection Pages

Custom Product Metafield for product labels/badges on Collection Pages

erin197
Visitor
1 0 0

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 -%}

Reply 1 (1)

PaulMartin
Shopify Partner
443 51 105

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!

Contact here for WhatsApp | Email
$20 start rate for theme fix & customization
Don't forget to like and mark as solution