-
Notifications
You must be signed in to change notification settings - Fork 35
/
script.liquid
77 lines (66 loc) · 1.83 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
65
66
67
68
69
70
71
72
73
74
75
76
77
{% assign email_subject = options.email_subject__required %}
{% assign email_body = options.email_body__multiline_required %}
{% assign tag_to_add_to_the_order = options.tag_to_add_to_the_order %}
{% comment %}
-- requery the order since a delay is typically configured in the task
{% endcomment %}
{% capture query %}
query {
order(id: {{ order.admin_graphql_api_id | json }}) {
id
email
cancelledAt
displayFinancialStatus
tags
}
}
{% endcapture %}
{% assign result = query | shopify %}
{% if event.preview %}
{% capture result_json %}
{
"data": {
"order": {
"id": "gid://shopify/Order/1234567890",
"email": "[email protected]",
"displayFinancialStatus": "PENDING"
}
}
}
{% endcapture %}
{% assign result = result_json | parse_json %}
{% endif %}
{% assign order = result.data.order %}
{% comment %}
-- don't send notification email if the order has no email, has been cancelled, or is no longer pending
{% endcomment %}
{% if order.email == blank or order.cancelledAt != blank or order.displayFinancialStatus != "PENDING" %}
{% break %}
{% endif %}
{% comment %}
-- send reminder email and tag the order if that option is configured
{% endcomment %}
{% action "email" %}
{
"to": {{ order.email | json }},
"subject": {{ email_subject | json }},
"body": {{ email_body | strip | newline_to_br | json }},
"reply_to": {{ shop.customer_email | json }},
"from_display_name": {{ shop.name | json }}
}
{% endaction %}
{% if tag_to_add_to_the_order != blank %}
{% action "shopify" %}
mutation {
tagsAdd(
id: {{ order.id | json }}
tags: {{ tag_to_add_to_the_order | json }}
) {
userErrors {
field
message
}
}
}
{% endaction %}
{% endif %}