-
Notifications
You must be signed in to change notification settings - Fork 0
/
auto-copy-order-notes-to-the-customers-note.json
21 lines (21 loc) · 2.07 KB
/
auto-copy-order-notes-to-the-customers-note.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{
"docs": "This task appends order notes to the related customer's note, whenever the order note changes.",
"halt_action_run_sequence_on_error": false,
"name": "Auto-copy order notes to the customer's note",
"online_store_javascript": null,
"options": {
"note_prefix": "Order {{ order.name }}: "
},
"order_status_javascript": null,
"perform_action_runs_in_sequence": false,
"script": "{% assign order_qualifies = false %}\n\n{% if order.note != blank %}\n {% unless order.customer.note contains order.note %}\n {% assign order_qualifies = true %}\n {% endunless %}\n{% endif %}\n\n{% if event.preview or order_qualifies %}\n {% assign new_order_note = order.customer.note | append: newline | append: newline | append: options.note_prefix | append: order.note | strip %}\n\n {% if event.preview or new_order_note.size <= 5000 %}\n {% action \"shopify\" %}\n [\n \"update\",\n [\n \"customer\",\n {{ order.customer.id | json }}\n ],\n {\n \"note\": {{ new_order_note | json }}\n }\n ]\n {% endaction %}\n {% else %}\n {% capture error_body %}\n Hello,\n \n Mechanic was unable to add to the customer note for the following customer, for the following related order:\n\n Customer: https://{{ shop.domain }}/admin/customers/{{ order.customer.id }}\n Order: https://{{ shop.domain }}/admin/orders/{{ order.id }}\n\n Thanks,\n Mechanic\n {% endcapture %}\n\n {% action \"email\" %}\n {\n \"to\": {{ shop.email | json }},\n \"subject\": {{ \"Mechanic error: customer note too long for order \" | append: order.name | json }},\n \"body\": {{ error_body | unindent | strip | newline_to_br | json }},\n \"reply_to\": {{ shop.customer_email | json }},\n \"from_display_name\": {{ shop.name | json }}\n }\n {% endaction %}\n {% endif %}\n{% endif %}",
"subscriptions": [
"shopify/orders/updated"
],
"subscriptions_template": "shopify/orders/updated",
"tags": [
"Customer Notes",
"Order Note",
"Sync"
]
}