forked from lightward/mechanic-tasks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto-prefix-tracking-numbers-for-each-new-fulfillment.json
22 lines (22 loc) · 1.69 KB
/
auto-prefix-tracking-numbers-for-each-new-fulfillment.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
"docs": "This task runs immediately after each new fulfillment is created, and adds a prefix to its tracking number, if a tracking number is present.",
"halt_action_run_sequence_on_error": false,
"name": "Auto-prefix tracking numbers for each new fulfillment",
"online_store_javascript": null,
"options": {
"tracking_number_prefix_to_add__required": null,
"notify_customer__boolean": false
},
"order_status_javascript": null,
"perform_action_runs_in_sequence": false,
"script": "{% if event.preview %}\n {% assign fulfillment = hash %}\n {% assign fulfillment[\"tracking_number\"] = \"1234567890\" %}\n {% assign fulfillment[\"admin_graphql_api_id\"] = \"gid://shopify/Fulfillment/1234567890\" %}\n{% endif %}\n\n{% if fulfillment.tracking_number == blank %}\n {\"log\": \"This fullfilment has no tracking number; can't add a prefix\"}\n{% else %}\n {% action \"shopify\" %}\n mutation {\n fulfillmentTrackingInfoUpdate(\n fulfillmentId: {{ fulfillment.admin_graphql_api_id | json }}\n trackingInfoUpdateInput: {\n trackingDetails: {\n number: {{ fulfillment.tracking_number | prepend: options.tracking_number_prefix_to_add__required | json }}\n }\n notifyCustomer: {{ options.notify_customer__boolean | json }}\n }\n ) {\n fulfillment {\n trackingInfo {\n number\n }\n }\n userErrors {\n field\n message\n }\n }\n }\n {% endaction %}\n{% endif %}",
"subscriptions": [
"shopify/fulfillments/create"
],
"subscriptions_template": "shopify/fulfillments/create",
"tags": [
"Fulfillment",
"Shipping",
"Tracking"
]
}