Mechanic Get Mechanic
Task library

Auto-add an order note for customers having a certain tag

This task monitors newly-created orders, and appends an order note if the customer has a certain tag. Useful for identifying orders for a particular customer group, and adding fulfillment notes as appropriate.

Try this task

When it runs

Occurs whenever an order is created

What you choose

  • Required customer tag
  • Order note to add
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

Task code

{% assign required_customer_tag_downcased = options.required_customer_tag__required | downcase %}

{% if event.preview %}
  {% capture order_json %}
    {
      "note": "An existing order note",
      "name": "#9999",
      "admin_graphql_api_id": "gid:\/\/shopify\/Order\/1234567890",
      "customer": {
        "tags": {{ options.required_customer_tag__required | json }}
      }
    }
  {% endcapture %}

  {% assign order = order_json | parse_json %}
{% endif %}

{% assign customer_tags_downcased = order.customer.tags | downcase | split: ", " %}
{% if customer_tags_downcased contains required_customer_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 %}
{% endif %}
Mechanic Liquid reference