Notify a team when a tagged product is ordered
Quickly route order notifications to whichever teams need be alerted for a given order. Use product tags to mark products according to which team needs the alert, and add multiple copies of this task to alert different teams for different tags.
Try this taskWhen it runs
Occurs whenever an order is created
What you choose
- Required product tag
- Team email
- Email subject
- Email body
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 product tag (required)
- Team email (required)
- Email subject (required)
- Email body (multiline, required)
Task code
{% assign required_product_tag = options.required_product_tag__required %}
{% assign team_email = options.team_email__required %}
{% assign email_subject = options.email_subject__required %}
{% assign email_body = options.email_body__multiline_required %}
{% comment %}
-- query the order, line items, products, and tags
{% endcomment %}
{% capture query %}
query {
order(id: {{ order.admin_graphql_api_id | json }}) {
id
tags
lineItems(first: 250) {
nodes {
product {
tags
}
}
}
}
}
{% endcapture %}
{% assign result = query | shopify %}
{% if event.preview %}
{% capture result_json %}
{
"data": {
"order": {
"id": "gid://shopify/Order/1234567890",
"lineItems": {
"nodes": [
{
"product": {
"tags": {{ required_product_tag | json }}
}
}
]
}
}
}
}
{% endcapture %}
{% assign result = result_json | parse_json %}
{% endif %}
{% assign products = result.data.order.lineItems.nodes | map: "product" %}
{% comment %}
-- loop through tags of products, sending the team email and breaking the loop when a match is found
{% endcomment %}
{% for product in products %}
{% if product.tags contains required_product_tag %}
{% action "email" %}
{
"to": {{ team_email | json }},
"subject": {{ email_subject | json }},
"body": {{ email_body | strip | newline_to_br | json }},
"reply_to": {{ shop.customer_email | json }},
"from_display_name": {{ shop.name | json }}
}
{% endaction %}
{% break %}
{% endif %}
{% endfor %}
Mechanic Liquid reference
Default option values
- Required product tag
requires-art- Team email
art-department@example.com- Email subject
Order {{ order.order_number }} requires custom artwork- Email body
Hello, Please see details for order {{ order.order_number }}: https://{{ shop.myshopify_domain }}/admin/orders/{{ order.id }} Thanks, - Mechanic, for {{ shop.name }}