Liquid, JavaScript, themes, sales channels
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
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_'.
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.
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024