Sao Ho
Sao Ho

Reputation: 139

Is it possible to add more values in a for in loop Liquid Shopify?

Here's my code

{% for filter_prefix in filter_prefixes %}
{{ filter_prefix }}
{% endfor %}

There are some values I want to add to the filter_prefixes, example: Type... Can I do it like this?

{% for filter_prefix in filter_prefixes %}
{% filter_prefix = 'Type' %}
{{ filter_prefix }}
{% endfor %}

To list all the filter_prefixes and added the Type value as well.

Please help me with this.

Thank you!

Upvotes: 0

Views: 765

Answers (1)

David Lazar
David Lazar

Reputation: 11427

Just output the value you want. There is no need to add it to the loop since it is just something you output anyway.

Type
{% for filter_prefix in filter_prefixes %}
   {{ filter_prefix }}
{% endfor %}

Or use the Shopify Array filters split and join. So you join your existing array filter_prefixes into a string, append Type and then split that back into an array.

Upvotes: 1

Related Questions