Send email when an order comes in
Use this task to notify staff (or suppliers, or anyone!) of incoming orders. Optionally, choose to only be notified when orders are paid, or only for orders that contain at least one product with a certain tag.
Try this taskWhen it runs
Occurs whenever an order is created
What you choose
- Only for orders including this product tag
- Email recipients
- Email subject
- Email body
- Only for paid orders
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
{% if options.only_for_paid_orders__boolean %}
shopify/orders/paid
{% else %}
shopify/orders/create
{% endif %}
How task subscriptions work
Option types and flags
- Email recipients (required)
- Email subject (required)
- Email body (required, multiline)
- Only for paid orders (boolean)
Task code
{% assign only_for_orders_including_this_product_tag = options.only_for_orders_including_this_product_tag %}
{% assign email_recipients = options.email_recipients__required %}
{% assign email_subject = options.email_subject__required %}
{% assign email_body = options.email_body__required_multiline %}
{% if only_for_orders_including_this_product_tag == blank %}
{% assign order_qualifies = true %}
{% else %}
{% capture query %}
query {
order(id: {{ order.admin_graphql_api_id | json }}) {
lineItems(first: 250) {
nodes {
product {
tags
}
}
}
}
}
{% endcapture %}
{% assign result = query | shopify %}
{% if event.preview %}
{% capture result_json %}
{
"data": {
"order": {
"lineItems": {
"nodes": [
{
"product": {
"tags": {{ only_for_orders_including_this_product_tag | json }}
}
}
]
}
}
}
}
{% endcapture %}
{% assign result = result_json | parse_json %}
{% endif %}
{% for line_item in result.data.order.lineItems.nodes %}
{% if line_item.product.tags contains only_for_orders_including_this_product_tag %}
{% assign order_qualifies = true %}
{% break %}
{% endif %}
{% endfor %}
{% endif %}
{% if order_qualifies %}
{% action "email" %}
{
"to": {{ email_recipients | json }},
"subject": {{ email_subject | json }},
"body": {{ email_body | newline_to_br | json }},
"reply_to": {{ shop.customer_email | json }},
"from_display_name": {{ shop.name | json }}
}
{% endaction %}
{% endif %}
Mechanic Liquid reference
Default option values
- Email recipients
sales@example.com, production@example.com- Email subject
New {{ order.financial_status }} order: {{ order.name }}- Email body
Hi team, Please see details for order {{ order.name }}: https://{{ shop.myshopify_domain }}/admin/orders/{{ order.id }} Thanks, - Mechanic, for {{ shop.name }}- Only for paid orders
false