forked from lightward/mechanic-tasks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.liquid
63 lines (61 loc) · 1.53 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
{% capture newline %}
{% endcapture %}
{% if event.preview %}
{
"action": {
"type": "shopify",
"options": [
"update",
[
"order",
12345
],
{
"note": "(Note copied from customer)"
}
]
}
}
{% elsif event.topic == "shopify/orders/create" %}
{% if order.customer.note == blank %}
{"log": "No note on file for this customer; skipping order update"}
{% else %}
{
"action": {
"type": "shopify",
"options": [
"update",
[
"order",
{{ order.id | json }}
],
{
"note": {{ order.note | append: newline | append: newline | append: order.customer.note | strip | json }}
}
]
}
}
{% endif %}
{% elsif event.topic == "mechanic/user/trigger" %}
{% for order in shop.orders.open %}
{% assign order_note_downcased = order.note | downcase %}
{% assign customer_note_downcased = order.customer.note | downcase %}
{% unless customer_note_downcased == blank or order_note_downcased contains customer_note_downcased %}
{
"action": {
"type": "shopify",
"options": [
"update",
[
"order",
{{ order.id | json }}
],
{
"note": {{ order.note | append: newline | append: newline | append: order.customer.note | strip | json }}
}
]
}
}
{% endunless %}
{% endfor %}
{% endif %}