Archive orders on delivery, with Mechanic.

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

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.

Runs Occurs whenever a fulfillment event is created.

15-day free trial – unlimited tasks

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.

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/fulfillment_events/create
Tasks use subscriptions to sign up for specific kinds of events. Learn more
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 %}
Task code is written in Mechanic Liquid, an extension of open-source Liquid enhanced for automation. Learn more