Mechanic is a development and ecommerce automation platform for Shopify. :)
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.
Runs Occurs whenever an order is created. Configuration includes required product tag, team email, email subject, and email body.
Mechanic is designed to benefit everybody: merchants, customers, developers, agencies, Shopifolks, everybody.
That’s why we make it easy to configure automation without code, why we make it easy to tweak the underlying code once tasks are installed, and why we publish it all here for everyone to learn from.
(By the way, have you seen our documentation? Have you joined the Slack community?)
shopify/orders/create
{% 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 %}
requires-art
art-department@example.com
Order {{ order.order_number }} requires custom artworkHello,
Please see details for order {{ order.order_number }}:
https://{{ shop.myshopify_domain }}/admin/orders/{{ order.id }}
Thanks,
- Mechanic, for {{ shop.name }}