Mechanic is a development and ecommerce automation platform for Shopify. :)
Add a tag, have the order automatically archived/closed. Simple. :)
Runs Occurs whenever an order is created, Occurs whenever an order is updated, and Occurs when a user manually triggers the task. Configuration includes required tag and allow manual unarchiving of orders.
Add a tag, have the order automatically archived/closed. Simple. :)
This task monitors for new and updated orders, watching for the tag of your choice to be added. When the tag is found, this task will make sure the order is archived/closed.
Run this task manually to scan your older orders, archiving any that match your tag.
Enable "Allow manually unarchiving of orders" to have this task add a metafield to each order, as it archives them. The task will use this metafield as a reminder to not archive those orders in the future, regardless of what happens to them.
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?)
shopify/orders/create shopify/orders/updated mechanic/user/trigger
{% assign metafield_key = task.id | sha256 | slice: 0, 5 | prepend: "archived-" %} {% assign orders = array %} {% if event.preview or event.topic contains "shopify/orders/" %} {% assign orders[0] = order %} {% elsif event.topic == "mechanic/user/trigger" %} {% assign orders = shop.orders.open %} {% endif %} {% for order in orders %} {% assign order_tags = order.tags | downcase | split: ", " %} {% assign tag_to_match = options.required_tag__required | downcase | strip %} {% assign order_qualifies = false %} {% if order.closed_at == blank and order_tags contains tag_to_match %} {% assign order_qualifies = true %} {% endif %} {% if options.allow_manual_unarchiving_of_orders__boolean %} {% if order.metafields.mechanic[metafield_key] %} {% assign order_qualifies = false %} {% log "Order has previously been archived, and manual unarchiving is allowed. Skipping." %} {% endif %} {% endif %} {% if event.preview or order_qualifies %} {% action "shopify" %} mutation { orderClose( input: { id: {{ order.admin_graphql_api_id | json }} } ) { order { closed closedAt } userErrors { field message } } {% if options.allow_manual_unarchiving_of_orders__boolean %} orderUpdate( input: { id: {{ order.admin_graphql_api_id | json }} metafields: [ { namespace: "mechanic" key: {{ metafield_key | json }} type: "date_time" value: {{ "now" | date: "%FT%T%:z" | json }} } ] } ) { order { metafield( namespace: "mechanic" key: {{ metafield_key | json }} ) { id value } } userErrors { field message } } {% endif %} } {% endaction %} {% endif %} {% endfor %}
archive-me