Mechanic Get Mechanic
Task library

Auto-archive orders after fulfillment

Just as it says. :) Archives orders immediately upon fulfillment, or after a configurable number of days.

Try this task

When it runs

Occurs whenever an order is fulfilled

What you choose

Days to wait after fulfillment before archiving

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/orders/fulfilled{% if options.days_to_wait_after_fulfillment_before_archiving__number %}+{{ options.days_to_wait_after_fulfillment_before_archiving__number }}.days{% endif %}
How task subscriptions work

Option types and flags

Task code

{% if options.days_to_wait_after_fulfillment_before_archiving__number %}
  {% if options.days_to_wait_after_fulfillment_before_archiving__number <= 0 %}
    {"error": "'Days to wait after fulfillment before archiving', if set, must be greater than zero. :)"}
  {% endif %}
{% endif %}

{% if event.preview %}
  {% assign order = '{"admin_graphql_api_id": "gid://shopify/Order/1234567890","closed_at":null}' | parse_json %}
{% else %}
  {% assign order = order.reload %}
{% endif %}

{% if order.closed_at == blank %}
  {% action "shopify" %}
    mutation {
      orderClose(
        input: {
          id: {{ order.admin_graphql_api_id | json }}
        }
      ) {
        order {
          closed
          closedAt
        }
        userErrors {
          field
          message
        }
      }
    }
  {% endaction %}
{% endif %}
Mechanic Liquid reference