Send an email alert when a fulfillment is cancelled
Useful for keeping an eye on unexpected cancellations by third party shipping services.
Try this taskWhen it runs
Occurs whenever a fulfillment is updated
What you choose
- Email recipient
- Email subject
- Email body
Documentation
Useful for keeping an eye on unexpected cancellations by third party shipping services.
This task performs two actions: one to send an email, and one to "remember" that an email has been sent. (Without this second action, this task would send an email every time a cancelled fulfillment is updated.)
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/fulfillments/update
How task subscriptions work
Option types and flags
- Email recipient (email, required)
- Email subject (required)
- Email body (multiline, required)
Task code
{% assign fulfillment_qualifies = false %}
{% assign cache_key = task.id | append: fulfillment.id | sha256 %}
{% if fulfillment.status == "cancelled" and cache[cache_key] == blank %}
{% assign fulfillment_qualifies = true %}
{% endif %}
{% if event.preview or fulfillment_qualifies %}
{% action "email" %}
{
"to": {{ options.email_recipient__email_required | json }},
"subject": {{ options.email_subject__required | json }},
"body": {{ options.email_body__multiline_required | strip | newline_to_br | json }},
"reply_to": {{ shop.customer_email | json }},
"from_display_name": {{ shop.name | json }}
}
{% endaction %}
{% action "cache", "set", cache_key, true %}
{% endif %}
Mechanic Liquid reference
Default option values
- Email subject
A fulfillment for order {{ fulfillment.order.name | default: "an order" }} was cancelled- Email body
Hello, A fulfillment with {{ fulfillment.line_items.size }} line item(s) was cancelled. <a href="https://{{ shop.domain }}/admin/orders/{{ fulfillment.order.id }}">Manage this order in Shopify</a> Thanks, Mechanic, for {{ shop.name }}