Auto-add a note for new orders having a certain tag
This task monitors newly-created orders, and appends an order note if that order was created with a certain tag.
Try this taskWhen it runs
Occurs whenever an order is created
What you choose
- Required order tag
- Order note to add
Documentation
This task monitors newly-created orders, and appends an order note if that order was created with a certain tag.
Note: this task does not monitor order updates, and so tags added later will not add an order note.
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
- Required order tag (required)
- Order note to add (required, multiline)
Task code
{% assign required_tag_downcased = options.required_order_tag__required | downcase %}
{% if event.preview %}
{% capture order_json %}
{
"note": "An existing order note",
"name": "#9999",
"admin_graphql_api_id": "gid:\/\/shopify\/Order\/1234567890",
"tags": {{ options.required_order_tag__required | json }}
}
{% endcapture %}
{% assign order = order_json | parse_json %}
{% endif %}
{% assign tags_downcased = order.tags | downcase | split: ", " %}
{% if tags_downcased contains required_tag_downcased %}
{% assign note = order.note | append: newline | append: newline | append: options.order_note_to_add__required_multiline | strip %}
{% action "shopify" %}
mutation {
orderUpdate(
input: {
id: {{ order.admin_graphql_api_id | json }}
note: {{ note | json }}
}
) {
userErrors {
field
message
}
}
}
{% endaction %}
{% else %}
{% log order_tags: order.tags %}
{% endif %}
Mechanic Liquid reference
Default option values
- Required order tag
foo- Order note to add
bar