Re: Tags/badges

Solved

How can customers manage tag names via the backend in Shopify?

BayOfDenmark
Shopify Partner
10 1 2

Hello Shopify friends,

I am currently working on making it easier for my customer to manage tags/badges via the backend. (see attached)

attached.png

 

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

Accepted Solution (1)

okur90
Shopify Partner
126 20 19

This is an accepted solution.

Hi @BayOfDenmark 

 

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

 

 

Code Slingin, Pixel Wranglin - Laugh it up at onlinex.com.au

View solution in original post

Replies 2 (2)

okur90
Shopify Partner
126 20 19

This is an accepted solution.

Hi @BayOfDenmark 

 

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

 

 

Code Slingin, Pixel Wranglin - Laugh it up at onlinex.com.au
BayOfDenmark
Shopify Partner
10 1 2

Hi Okur90, you are a superstar! Thanks! it works 😀

Thanks for the quick response!

 

Cheers // Peter