-
Notifications
You must be signed in to change notification settings - Fork 35
/
delete-draft-orders.json
24 lines (24 loc) · 2.88 KB
/
delete-draft-orders.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
"docs": "Use this task to clear out your draft orders, on demand. Filter by draft order status (open, invoice sent, closed), or by draft order tags.\n\n**Important: Be sure to configure this task before running!** You may filter by draft order status (open, invoice sent, or closed), and by draft order tag (to selectively delete, or to selectively ignore).",
"halt_action_run_sequence_on_error": false,
"name": "Delete draft orders",
"online_store_javascript": null,
"options": {
"include_open_draft_orders__boolean": false,
"include_invoice_sent_draft_orders__boolean": false,
"include_closed_draft_orders__boolean": false,
"only_delete_draft_orders_having_this_tag": null,
"ignore_draft_orders_having_this_tag": null
},
"order_status_javascript": null,
"perform_action_runs_in_sequence": false,
"script": "{% if event.preview %}\n {\n \"action\": {\n \"type\": \"shopify\",\n \"options\": [\n \"delete\",\n [\n \"draft_order\",\n 1234567890\n ]\n ]\n }\n }\n{% else %}\n {% assign selectors = \"\" %}\n\n {% if options.include_open_draft_orders__boolean %}\n {% assign selectors = selectors | append: \",open\" %}\n {% endif %}\n {% if options.include_invoice_sent_draft_orders__boolean %}\n {% assign selectors = selectors | append: \",invoice_sent\" %}\n {% endif %}\n {% if options.include_closed_draft_orders__boolean %}\n {% assign selectors = selectors | append: \",closed\" %}\n {% endif %}\n\n {% assign selectors = selectors | slice: 1, 100 | split: \",\" %}\n {\"log\": {{ selectors | json }}}\n {\"log\": {{ options | json }}}\n\n {% for selector in selectors %}\n {% for draft_order in shop.draft_orders[selector] %}\n {% assign draft_order_qualifies = true %}\n {% assign draft_order_tags = draft_order.tags | split: \", \" %}\n\n {% if options.only_delete_draft_orders_having_this_tag != blank %}\n {% unless draft_order_tags contains options.only_delete_draft_orders_having_this_tag %}\n {% assign draft_order_qualifies = false %}\n {% endunless %}\n {% endif %}\n\n {% if options.ignore_draft_orders_having_this_tag != blank %}\n {% if draft_order_tags contains options.ignore_draft_orders_having_this_tag %}\n {% assign draft_order_qualifies = false %}\n {% endif %}\n {% endif %}\n\n {% if draft_order_qualifies %}\n {\n \"action\": {\n \"type\": \"shopify\",\n \"options\": [\n \"delete\",\n [\n \"draft_order\",\n {{ draft_order.id | json }}\n ]\n ]\n }\n }\n {% endif %}\n {% endfor %}\n {% endfor %}\n{% endif %}",
"subscriptions": [
"mechanic/user/trigger"
],
"subscriptions_template": "mechanic/user/trigger",
"tags": [
"Delete",
"Draft Orders"
]
}