Auto-tag new orders with a value from the customer note
This task watches incoming orders, and tags each order with a certain value from the customer's note, as identified by a configurable prefix. For example, if your customers have notes resembling "Username: xyz", configure this task with the prefix "Username: " to have it tag incoming orders as "xyz". Useful with apps like inkFrog, which add eBay usernames to customer notes, using a prefix.
Try this taskWhen it runs
Occurs whenever an order is created
What you choose
Tag prefix in customer note
Documentation
This task watches incoming orders, and tags each order with a certain value from the customer's note, as identified by a configurable prefix. For example, if your customers have notes resembling "Username: xyz", configure this task with the prefix "Username: " to have it tag incoming orders as "xyz". Useful with apps like inkFrog, which add eBay usernames to customer notes, using a prefix.
This task watches incoming orders, and tags each order with a certain value from the customer's note, as identified by a configurable prefix. For example, if your customers have notes resembling "Username: xyz", configure this task with the prefix "Username: " to have it tag incoming orders as "xyz".
Task code and subscriptions
You can edit the Liquid code after installing this task. View on GitHub or ask a question in the Mechanic Slack community.
Subscriptions
shopify/orders/create
How task subscriptions work
Option types and flags
- Tag prefix in customer note (required)
Task code
{% if event.preview %}
{% capture order_json %}
{
"admin_graphql_api_id": "gid://shopify/Order/12345",
"customer": {
"note": {{ options.tag_prefix_in_customer_note__required | append: "abc123" | json }}
}
}
{% endcapture %}
{% assign order = order_json | parse_json %}
{% endif %}
{% assign note_lines = order.customer.note | split: newline %}
{% assign desired_prefix = options.tag_prefix_in_customer_note__required %}
{% assign tag = nil %}
{% for line in note_lines %}
{% assign line_prefix = line | slice: 0, desired_prefix.size %}
{% if line_prefix == desired_prefix %}
{% assign tag = line | replace: line_prefix, "" %}
{% endif %}
{% endfor %}
{% if tag != blank %}
{% action "shopify" %}
mutation {
tagsAdd(
id: {{ order.admin_graphql_api_id | json }}
tags: {{ tag | json }}
) {
node {
... on Order {
tags
}
}
userErrors {
field
message
}
}
}
{% endaction %}
{% endif %}
Mechanic Liquid reference
Default option values
- Tag prefix in customer note
eBay User: