Archive orders on delivery
Don't keep your customers waiting! Stay on top of orders that have yet to be delivered, by auto-archiving every order once every item has reached the customer.
Try this taskWhen it runs
Occurs whenever a fulfillment event is created
Documentation
Don't keep your customers waiting! Stay on top of orders that have yet to be delivered, by auto-archiving every order once every item has reached the customer.
This task monitors fulfillment events. Every time a fulfillment event occurs, every fulfillment in the related order is scanned - once each fulfillment reaches the "delivered" status, this task archives the order.
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/fulfillment_events/create
How task subscriptions work
Task code
{% assign order_qualifies = false %}
{% assign order = fulfillment_event.order %}
{% if order.closed_at == blank %}
{% if order.fulfillment_status == "fulfilled" %}
{% assign shipment_statuses = order.fulfillments | map: "shipment_status" | uniq %}
{% if shipment_statuses.size == 1 and shipment_statuses.first == "delivered" %}
{% assign order_qualifies = true %}
{% else %}
{"log": {{ shipment_statuses | join: ", " | prepend: "Order is not fully delivered. Status(es) found: " | json }}}
{% endif %}
{% else %}
{"log": {{ "Order is not fulfilled; status is " | append: order.fulfillment_status | json }}}
{% endif %}
{% else %}
{"log": "Order is already closed."}
{% endif %}
{% if order_qualifies or event.preview %}
{
"action": {
"type": "shopify",
"options": [
"post",
"/admin/orders/{{ order.id | default: "0000" }}/close.json",
{}
]
}
}
{% endif %}
Mechanic Liquid reference