-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathscript.liquid
48 lines (42 loc) · 1.57 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
{% comment %}
An opinion about option order
{{ options.email_subject__required }}
{{ options.order_name_column__required }}
{{ options.prepend_pound_sign_to_order_name__boolean }}
{{ options.shipping_cost_column__required }}
{% endcomment %}
{% assign updates = array %}
{% if event.preview %}
{% assign update = hash %}
{% assign update["name"] = "#1234" %}
{% assign update["shipping_cost"] = 1.23 %}
{% assign updates[updates.size] = update %}
{% assign email = hash %}
{% assign email["subject"] = options.email_subject__required %}
{% endif %}
{% if email.subject == options.email_subject__required %}
{% for attachment in email.attachments %}
{% assign shipments = attachment.content | decode_base64 | parse_csv: headers: true %}
{% for shipment in shipments %}
{% assign order_name = shipment[options.order_name_column__required] %}
{% assign shipping_cost = shipment[options.shipping_cost_column__required] %}
{% if order_name != blank %}
{% if options.prepend_pound_sign_to_order_name__boolean %}
{% assign order_name = order_name | prepend: "#" %}
{% endif %}
{% assign update = hash %}
{% assign update["name"] = order_name %}
{% assign update["shipping_cost"] = shipping_cost %}
{% assign updates[updates.size] = update %}
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
{% if updates != empty %}
{% action "report_toaster" %}
{
"operation": "update",
"Order": {{ updates | json }}
}
{% endaction %}
{% endif %}