Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
I would like to run a flow that adds a customer metafield value as a order tag. Currently I have the below as the rule, but it is not working.
Start when...Order Created
Do this... Add order tags
Add the following order tags:
{% for mf in order.customer.metafields %} {% if mf.namespace == 'global' and mf.key == 'slspsn_name' %} {{ mf.value }}{% endif %}{% endfor %}
Any advice for an edit to make this work?
What is not working? Have you looked at the workflow run? Is there an error or are you not seeing the tag? Things I'd look at:
All orders have customers, and the ones with errors have the specific metafield filled out.
The error is "Order tags is invalid".
Here are some screenshots of the most recent error, the order # and the metafield for the customer.
Tags has limitations based on length and type of characters allowed. Does that salesperson name have any characters in it? Or is it long?
Its long with a phone number and email address - I just tried manually adding it and got an error. ill try another metafield thats more simple - thank you!
Cool, you can use liquid to find-and-replace or truncate the text, if needed.
Hey Paul
Lets say the full metafield value is "John Doe 555-555-5555 name@email.com"
Is it possible to change the tag to say something different? If metafield is above, than tag "JOHDOE"
If metafield = "Jack Black 555-555-5555 name@email.com"
Tag order with "JACBLA"
Would the tag code look something like this? Please correct if its wrong...
{% for mf in order.customer.metafields %} {% if mf.namespace == 'global' and mf.key == 'slspsn_name' and mf.value == 'John Doe 555-555-5555 name@email.com' %} {{ JOHDOE }}{% endif %}{% endfor %}
{% for mf in order.customer.metafields %} {% if mf.namespace == 'global' and mf.key == 'slspsn_name' and mf.value == 'Jack Black 555-555-5555 name@email.com' %} {{ JACBLA }}{% endif %}{% endfor %}
You could split by spaces and then output the first two items for the name. Something like:
{% assign names = mf.value | split: " " %}
{% for name in names %}
{% if forloop.counter <= 2 %}{{ name }}{% endif %}
{% endfor %}
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024