Can Shopify Flow combine two product tags based on conditions?

Solved

Can Shopify Flow combine two product tags based on conditions?

DeltaDan
Shopify Partner
4 0 0

Is it possible to set up a Shopify Flow to combine elements of two tags if they both exist on a product when it is created? For instance: let's say I have a pair of men's 32x34 pants. I want to input the size attributes independently, but I want to see if it's possible to automatically combine them together.

 

Tag - waist_32

Tag - length_34

 

I've been able to set up the Shopify Flow Condition to be if tags exist that start with "waist_" and "length_", then... but haven't been able to figure out how to combine these into one single tag. Thoughts?

Accepted Solution (1)
paul_n
Shopify Staff
1501 161 350

This is an accepted solution.

Yes, it's possible. I'm guessing you don't have experience with liquid? 

You may be able to copy and paste this into the Add product tag action:

{%- for tg in product.tags %}
{% if tg contains "waist_" %}
{%- assign part1 = tg | replace: "waist_","" -%}
{% elsif tg contains "length_" %}
{%- assign part2 = tg | replace: "length_","" -%}
{% endif %}
{% endfor -%}
{%- if part1 != nil and part2 != nil -%}size_{{ part1 }}x{{ part2 -}}{% endif %}
 
Note: if there are multiple waist_ or length_ it will not handle that gracefully, so you'll need to modify it based on that. 
Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.

View solution in original post

Replies 5 (5)

paul_n
Shopify Staff
1501 161 350

Yes, assuming you are adding the combo as a new tag, you can write liquid in the tag field to combine them like {{tag1}}-{{tag2}}. Make sure you change the names to use the right variables and hit enter to add it as a tag in the tag action. 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
DeltaDan
Shopify Partner
4 0 0

Can you just keep part of the tag? Rather than the new tag being "waist_32lengh_34", can I build logic to make it "size_32x34"?

paul_n
Shopify Staff
1501 161 350

You cannot edit tags. You remove or add them. So you would need to remove the previous tags and add the new tags.

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
DeltaDan
Shopify Partner
4 0 0

Sorry if that wasn't clear. I'm not looking to edit - I'm just looking to create a new tag based on parts of existing tags. So ideally it would be:

 

Original Product Tags:

  • waist_32
  • length_34

End Product Tags:

  • waist_32
  • length_34
  • size_32x34

Is this possible in Shopify Flow?

paul_n
Shopify Staff
1501 161 350

This is an accepted solution.

Yes, it's possible. I'm guessing you don't have experience with liquid? 

You may be able to copy and paste this into the Add product tag action:

{%- for tg in product.tags %}
{% if tg contains "waist_" %}
{%- assign part1 = tg | replace: "waist_","" -%}
{% elsif tg contains "length_" %}
{%- assign part2 = tg | replace: "length_","" -%}
{% endif %}
{% endfor -%}
{%- if part1 != nil and part2 != nil -%}size_{{ part1 }}x{{ part2 -}}{% endif %}
 
Note: if there are multiple waist_ or length_ it will not handle that gracefully, so you'll need to modify it based on that. 
Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.