All things Shopify and commerce
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
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