-
Notifications
You must be signed in to change notification settings - Fork 35
/
script.liquid
64 lines (58 loc) · 1.79 KB
/
script.liquid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{% if event.preview %}
{
"action": {
"type": "shopify",
"options": [
"delete",
[
"draft_order",
1234567890
]
]
}
}
{% else %}
{% assign selectors = "" %}
{% if options.include_open_draft_orders__boolean %}
{% assign selectors = selectors | append: ",open" %}
{% endif %}
{% if options.include_invoice_sent_draft_orders__boolean %}
{% assign selectors = selectors | append: ",invoice_sent" %}
{% endif %}
{% if options.include_closed_draft_orders__boolean %}
{% assign selectors = selectors | append: ",closed" %}
{% endif %}
{% assign selectors = selectors | slice: 1, 100 | split: "," %}
{"log": {{ selectors | json }}}
{"log": {{ options | json }}}
{% for selector in selectors %}
{% for draft_order in shop.draft_orders[selector] %}
{% assign draft_order_qualifies = true %}
{% assign draft_order_tags = draft_order.tags | split: ", " %}
{% if options.only_delete_draft_orders_having_this_tag != blank %}
{% unless draft_order_tags contains options.only_delete_draft_orders_having_this_tag %}
{% assign draft_order_qualifies = false %}
{% endunless %}
{% endif %}
{% if options.ignore_draft_orders_having_this_tag != blank %}
{% if draft_order_tags contains options.ignore_draft_orders_having_this_tag %}
{% assign draft_order_qualifies = false %}
{% endif %}
{% endif %}
{% if draft_order_qualifies %}
{
"action": {
"type": "shopify",
"options": [
"delete",
[
"draft_order",
{{ draft_order.id | json }}
]
]
}
}
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}