forked from lightward/mechanic-tasks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremind-customers-that-their-order-is-on-the-way.json
27 lines (27 loc) · 6.17 KB
/
remind-customers-that-their-order-is-on-the-way.json
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
{
"docs": "Do you ship custom items, or do you have a lengthy turnaround time on your orders? Use this task to automatically re-assure customers that their order is in the queue, to be shipped as soon as possible. By default, this task sends an email 10 days (or a number you configure) after the order is paid, as long as the order remains fully paid, unfulfilled, and un-cancelled. Optionally, configure tags to add to the order and/or customer, to be added when the email is sent, and choose whether to only send reminders on weekdays.\n\nUse the variables ORDER_NUMBER and CUSTOMER_FIRST_NAME to insert each of these values into your email subject and body respectively.\n\nNote: When the \"Only send reminders on weekdays\" option is chosen, any emails that would have been sent on a weekend are instead emailed the following Monday.",
"halt_action_run_sequence_on_error": false,
"name": "Remind customers that their order is on the way",
"online_store_javascript": null,
"options": {
"number_of_days_to_wait__number_required": "10",
"only_send_reminders_on_weekdays__boolean": false,
"email_subject__required": "Don't worry – ORDER_NAME is still coming!",
"email_body__multiline_required": "Hi CUSTOMER_FIRST_NAME,\n\nThank you for your order! We're writing to let you know that your order is still enqueued, and will be shipped to you as soon as it's ready. :)\n\nJust reply to this email if you have any questions.\n\nThanks,\n{{ shop.name }}",
"tag_to_add_to_order": null,
"tag_to_add_to_customer": null
},
"order_status_javascript": null,
"perform_action_runs_in_sequence": false,
"script": "{% if event.topic == \"shopify/orders/paid\" %}\n {% if event.preview %}\n {% assign order = hash %}\n {% assign order[\"admin_graphql_api_id\"] = \"gid://shopify/Order/1234567890\" %}\n {% assign order[\"fulfillment_status\"] = nil %}\n {% endif %}\n\n {% if order.fulfillment_status == blank or order.fulfillment_status == \"partial\" %}\n {% assign one_day_in_seconds = 60 | times: 60 | times: 24 %}\n {% assign days_to_wait = options.number_of_days_to_wait__number_required | default: 10 %}\n {% assign days_to_wait_in_seconds = days_to_wait | times: one_day_in_seconds %}\n {% assign run_at = \"now\" | date: \"%s\" | plus: days_to_wait_in_seconds %}\n\n {% if options.only_send_reminders_on_weekdays__boolean %}\n {% assign run_at_day = run_at | date: \"%w\" %}\n\n {% if run_at_day == \"0\" %}{% comment %}-- Sunday --{% endcomment %}\n {% assign run_at = run_at | plus: one_day_in_seconds %}\n {% elsif run_at_day == \"6\" %}{% comment %}-- Saturday --{% endcomment %}\n {% assign run_at = run_at | plus: one_day_in_seconds | plus: one_day_in_seconds %}\n {% endif %}\n {% endif %}\n\n {% action \"event\" %}\n {\n \"topic\": \"user/order/customer_reminder\",\n \"task_id\": {{ task.id | json }},\n \"run_at\": {{ run_at | json }},\n \"data\": {\n \"order_id\": {{ order.admin_graphql_api_id | json }}\n }\n }\n {% endaction %}\n {% endif %}\n{% elsif event.topic == \"user/order/customer_reminder\" %}\n {% assign order_id = event.data.order_id %}\n\n {% capture order_query %}\n query {\n order(id: {{ order_id | json }}) {\n id\n name\n email\n fullyPaid\n displayFulfillmentStatus\n cancelledAt\n customer {\n id\n firstName\n }\n }\n }\n {% endcapture %}\n\n {% assign order_result = order_query | shopify %}\n\n {% if event.preview %}\n {% capture order_result_json %}\n {\n \"data\": {\n \"order\": {\n \"id\": \"gid://shopify/Order/1234567890\",\n \"name\": \"#1234\",\n \"email\": \"[email protected]\",\n \"fullyPaid\": true,\n \"displayFulfillmentStatus\": \"UNFULFILLED\",\n \"cancelledAt\": null,\n \"customer\": {\n \"id\": \"gid://shopify/Customer/1234567890\",\n \"firstName\": \"Charlie\"\n }\n }\n }\n }\n {% endcapture %}\n\n {% assign order_result = order_result_json | parse_json %}\n {% endif %}\n\n {% assign order = order_result.data.order %}\n\n {% if order.cancelledAt == blank and order.fullyPaid %}\n {% if order.displayFulfillmentStatus == \"UNFULFILLED\" or order.displayFulfillmentStatus == \"PARTIALLY_FULFILLED\" %}\n {% assign customer_first_name = order.customer.firstName | default: \"there\" %}\n {% assign email_subject = options.email_subject__required | replace: \"ORDER_NAME\", order.name %}\n {% assign email_body = options.email_body__multiline_required | strip | newline_to_br | replace: \"CUSTOMER_FIRST_NAME\", customer_first_name %}\n\n {% action \"email\" %}\n {\n \"to\": {{ order.email | json }},\n \"subject\": {{ email_subject | json }},\n \"body\": {{ email_body | json }},\n \"reply_to\": {{ shop.customer_email | json }},\n \"from_display_name\": {{ shop.name | json }}\n }\n {% endaction %}\n\n {% if options.tag_to_add_to_order != blank %}\n {% action \"shopify\" %}\n mutation {\n tagsAdd(\n id: {{ order.id | json }}\n tags: {{ options.tag_to_add_to_order | json }}\n ) {\n userErrors {\n field\n message\n }\n }\n }\n {% endaction %}\n {% endif %}\n\n {% if options.tag_to_add_to_customer != blank %}\n {% action \"shopify\" %}\n mutation {\n tagsAdd(\n id: {{ order.customer.id | json }}\n tags: {{ options.tag_to_add_to_customer | json }}\n ) {\n userErrors {\n field\n message\n }\n }\n }\n {% endaction %}\n {% endif %}\n {% endif %}\n {% endif %}\n{% endif %}",
"subscriptions": [
"shopify/orders/paid",
"user/order/customer_reminder"
],
"subscriptions_template": "shopify/orders/paid\nuser/order/customer_reminder",
"tags": [
"Email",
"Reminder",
"Shipping"
]
}