Send an email alert when a fulfillment is cancelled, with Mechanic.

Mechanic is a development and ecommerce automation platform for Shopify. :)

Send an email alert when a fulfillment is cancelled

Useful for keeping an eye on unexpected cancellations by third party shipping services.

Runs Occurs whenever a fulfillment is updated. Configuration includes email recipient, email subject, and email body.

15-day free trial – unlimited tasks

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.)

Developer details

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?)

Open source
View on GitHub to contribute to this task
Subscriptions
shopify/fulfillments/update
Tasks use subscriptions to sign up for specific kinds of events. Learn more
Options
email recipient (email, required), email subject (required), email body (multiline, required)
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 %}
Task code is written in Mechanic Liquid, an extension of open-source Liquid enhanced for automation. Learn more
Defaults
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 }}