-
Notifications
You must be signed in to change notification settings - Fork 35
/
archive-orders-when-fulfilled.json
20 lines (20 loc) · 1.89 KB
/
archive-orders-when-fulfilled.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
"docs": "Super simple: this task monitors for order fulfillments, and automatically archives orders when they're fulfilled.\n\nThis task runs automatically, when orders are fulfilled. To scan your store's order history and archive all _existing_ fulfilled orders, use the \"Run task\" button. [Enable \"Read all orders\"](https://help.usemechanic.com/tutorials/enabling-read_all_orders) to make sure Mechanic can scan your entire order history, and not just the last 60 days.",
"halt_action_run_sequence_on_error": false,
"name": "Archive orders when fulfilled",
"online_store_javascript": null,
"options": {},
"order_status_javascript": null,
"perform_action_runs_in_sequence": false,
"script": "{% if event.topic == \"mechanic/user/trigger\" %}\n {% if event.preview %}\n {\n \"action\": {\n \"type\": \"shopify\",\n \"options\": [\n \"post\",\n \"/admin/orders/1234567890/close.json\",\n {}\n ]\n }\n }\n {% else %}\n {% for order in shop.orders.any.shipped.open %}\n {\n \"action\": {\n \"type\": \"shopify\",\n \"options\": [\n \"post\",\n \"/admin/orders/{{ order.id | default: \"1234567890\" }}/close.json\",\n {}\n ]\n }\n }\n {% endfor %}\n {% endif %}\n{% elsif event.topic == \"shopify/orders/fulfilled\" %}\n {% if order.closed_at == blank or event.preview %}\n {\n \"action\": {\n \"type\": \"shopify\",\n \"options\": [\n \"post\",\n \"/admin/orders/{{ order.id | default: \"1234567890\" }}/close.json\",\n {}\n ]\n }\n }\n {% endif %}\n{% endif %}",
"subscriptions": [
"shopify/orders/fulfilled",
"mechanic/user/trigger"
],
"subscriptions_template": "shopify/orders/fulfilled\r\nmechanic/user/trigger",
"tags": [
"Archive",
"Fulfillment",
"Orders"
]
}