All things Shopify and commerce
Hello Shopify friends,
I am currently working on making it easier for my customer to manage tags/badges via the backend. (see attached)
Code working:
{% for tag in product.tags %}
{% if tag contains "Bestseller" %}
<span class="custom-tags"> {{ tag }} </span>
{% endif %}
{% than before %}
which works fine, but I would like the customer to be able to enter the tag name themselves in a text field via the backend. So I tried putting "{{ section.settings.badge_name }}" instead of "Bestseller" but it doesn't work.
Code not working:
{% for tag in product.tags %}
{% if tag contains "{{ section.settings.badge_name }}" %}
<span class="custom-tags"> {{ tag }} </span>
{% endif %}
{% than before %}
Does anyone have a solution to this problem..?
Cheers // Peter
Solved! Go to the solution
This is an accepted solution.
can you try the below code?
{% for tag in product.tags %}
{% if tag contains section.settings.badge_name %}
<span class="custom-tags"> {{ tag }} </span>
{% endif %}
{% endfor %}
Also, you should define the `badge_name` setting in your `schema` block like this
{
"type": "text",
"id": "badge_name",
"label": "Badge Name",
"default": "Bestseller"
}
This is an accepted solution.
can you try the below code?
{% for tag in product.tags %}
{% if tag contains section.settings.badge_name %}
<span class="custom-tags"> {{ tag }} </span>
{% endif %}
{% endfor %}
Also, you should define the `badge_name` setting in your `schema` block like this
{
"type": "text",
"id": "badge_name",
"label": "Badge Name",
"default": "Bestseller"
}
Hi Okur90, you are a superstar! Thanks! it works 😀
Thanks for the quick response!
Cheers // Peter
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025