Mechanic Get Mechanic
Task library

Email someone specific based on a new order's customer tags

Use customer tags to assign staff email addresses to specific customers. When a new order arrives from a customer who has an assignment tag, this task will email the related staff member.

Try this task

When it runs

Occurs whenever an order is created

What you choose

  • Customer tags and assigned email recipients
  • Email subject
  • Email body

Documentation

Use customer tags to assign staff email addresses to specific customers. When a new order arrives from a customer who has an assignment tag, this task will email the related staff member.

Fill in the "Customer tags and assigned email recipients" option with customer tags on the left (case-insensitive), and staff email addresses on the right. When this task registers a newly-created order with a customer tag that's found in the list, it will send an email to the appropriate email address. If multiple assignment tags are found for the customer, the email will be sent to all related staff members.

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 customer_tags = order.customer.tags | downcase | split: ", " %}

{% assign email_recipients = array %}

{% for keyval in options.customer_tags_and_assigned_email_recipients__keyval_required %}
  {% assign assigned_tag = keyval[0] | downcase %}
  {% assign assigned_email = keyval[1] %}

  {% if customer_tags contains assigned_tag %}
    {% assign email_recipients[email_recipients.size] = assigned_email %}
  {% endif %}
{% endfor %}

{% if event.preview or email_recipients != empty %}
  {% action "email" %}
    {
      "to": {{ email_recipients | join: ", " | json }},
      "subject": {{ options.email_subject__required | json }},
      "body": {{ options.email_body__required_multiline | newline_to_br | json }},
      "reply_to": {{ shop.customer_email | json }},
      "from_display_name": {{ shop.name | json }}
    }
  {% endaction %}
{% endif %}
Mechanic Liquid reference

Default option values

Customer tags and assigned email recipients
{}
Email subject
Order {{ order.name }} from your customer, {{ order.email }}
Email body
Hello,

Order {{ order.name }} has arrived from {{ order.customer.first_name | default: "(first name)" }} {{ order.customer.last_name | default: "(last name)" }} ({{ order.email }}).

<a href="https://{{ shop.domain }}/admin/orders/{{ order.id }}">View this order in Shopify</a>

Thanks,
Mechanic, for {{ shop.name }}