How can I add an order tag to the liquid template for retail and wholesale?

tdestira
Tourist
4 0 1

How do you add an order tag to the liquid template? I know very little about coding and  want to be able to distinguish between retail and wholesale orders. 

These are what I've tried so far and none of them have worked: 

{% for tag in order.tags %}
  {% if tag contains "wholesale" %}
         <p> {{ tag }}</p>
  {% endif %}
{% endfor %}

 

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

 

{% for tag in order.tags %}                                                                                                                         
     {% if tag.contains "wholesale" %}                                                                                                        
       {% assign tag = wholesale %}                                                                                                                     
     {% endif %}
{% endfor %}

 

Thanks for any help! 

Replies 6 (6)

JoesIdeas
Shopify Expert
2263 207 599

If you're doing this in the order notification email, try this:

 

{% for tag in tags %}
  {% if tag contains "wholesale" %}
    <p>{{ tag }}</p>
  {% endif %}
{% endfor %}

 

With those notifications it already accesses the order object, so you go directly to the property (tags). Reference: https://help.shopify.com/en/manual/orders/notifications/email-variables#order-fulfillment

 

 

• Creator of Order Automator (automate tagging, fulfillment, Amazon, notifications + more)
• Shopify developer for 10+ years, store owner for 7 years
• I also make guides like Shopify Automation Tips and How to Deal with Fraud / Chargebacks
tdestira
Tourist
4 0 1

Sorry I didn't really specify. I'm trying to add to our invoice so for the order printer template. 

JaRet_Watkins
Excursionist
20 1 5

I'm having the same issue. What I found in the documentation is that order printer does not have access to order.tags, which is why the code blocks above don't work. Were you able to find a fix?

applecrestfarm
Visitor
1 0 0

did you ever find a solution to this? I need the tags to show up on my invoice

tdestira
Tourist
4 0 1
Unfortunately, no. I haven't found a solution yet.

ghengis
Visitor
2 0 0

You can now do this in a way with the TagRobot app. At the same time it adds a tag to your order, it can add a tag to an array that is readable in Order Printer. No way to delete that array, but it can be used to pass data on. Very easy to use. And it's not the Tags array, but a TagRobot Array. Solves the issue and just came out.