{% for tag in order.tags %} Trying to add tags to printed order

Michelt
New Member
4 0 0

From documentation

{% for tag in order.tags %} {{ tag }} {% endfor %}

I want to assign a variable and ideally only show the first 2 characters of each tag on an order printed using splice 2,0

{% assign O_tags = "1_" %}
{% for tag in order.tags %}

{{ assign O_tags | append : tag }}
{% endfor %}

My initial variable 1_ outputs but the for tag in order.tags gives zero results in Order Printer Pro template

I have made many changes to the order template in order printer pro and all work fine

Any ideas ?

Thanks

Michel T, Alexandria, Ont Canada

0 Likes

Looks like the splice parameters are backward. Should be:

{{ tag | slice: 0,2 }}

I like the following solution for this:

{%- for tag in order.tags -%}{{ tag | slice: 0,2 }}{%- endfor -%}

Note the '%-' is used to remove the white space.

Here is a solution closer to the way you have framed it:

{% assign O_tags = "1_" %}
{% for tag in order.tags %}
{% assign O_tag_item = tag | slice: 0,2 %}
{% assign O_tags = O_tags | append : O_tag_item %}
{% endfor %}
result: {{ O_tags }}

This will print the first two characters of each tag on an order prepended with '1_'.

 

 

 

 

 

 

If my response was helpful please Like and Mark As Solution.
0 Likes
Michelt
New Member
4 0 0
Thanks for the suggestion.

I am not getting any output.
As if no tag info is found.
I tried with many different orders that have tags.
Is it possible the order printer pro APP does not have access to order.tags ?

PS: Do you know how to de-activate typo tolerance for search ? My friend's site(itpartsource.com/), he is going crazy because searchis recommending wrong parts to his customers based on typo tolerance.

0 Likes

You can use the following code to determine if the order object has any items in the tags property:

Tags: {{ order.tags.size }}

 Sorry, I'm not familiar with how Order Printer Pro app handles order.tags and I'd have to see a couple of examples before I can weigh in on the typo tolerance issue.

 

If my response was helpful please Like and Mark As Solution.
0 Likes