Re: Packing slip template liquid operator ends up with duplicate

Solved

Packing slip template liquid operator ends up with duplicate

Djurmamman
Explorer
63 4 11

Why does this liquid in the packing slip template 

{% for tag in order.tags %}
	{% if tag != 'wholesale' %}
		<p>B2C</p>
	{% else %}
		<p>B2B</p>
	{% endif %}
{% endfor %}

 Result in

B2C
B2C

when i print packing slip from a order that does not include the tag wholesale?

 

If i print packing slip from order with wholesale tag it prints B2B one time.

Accepted Solution (1)

tim
Shopify Partner
3630 314 1343

This is an accepted solution.

Hey, your code loops over order tags and for each of them outputs something. So, if the order has 2 tags, it will output 2 lines, if order has 3 tags it will produce 3 lines.

I'd suggest this code instead:

{% if order.tags contains "wholesale" %}
  B2B
{% else %}
  B2C
{% endif %}

 

If my post is helpful, consider liking it -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com

View solution in original post

Replies 2 (2)

tim
Shopify Partner
3630 314 1343

This is an accepted solution.

Hey, your code loops over order tags and for each of them outputs something. So, if the order has 2 tags, it will output 2 lines, if order has 3 tags it will produce 3 lines.

I'd suggest this code instead:

{% if order.tags contains "wholesale" %}
  B2B
{% else %}
  B2C
{% endif %}

 

If my post is helpful, consider liking it -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com
Djurmamman
Explorer
63 4 11

Thats it! Thanks Tim.