Setting the file. One moment. Order Created Run Code · Shopify · Shopify/Shopify-AI-Toolkit · Skills Docs22.11
Onboarding Merchant
(opens in a new tab)
assets/flow/order-created-run-code.json
JSON·89 lines·3 KB
"TRIGGER"
,
12 "config_field_values": []
13 },
14 {
15 "step_id": "total_fragile_items",
16 "task_id": "shopify::flow::run_code",
17 "task_version": "0.1",
18 "task_type": "ACTION",
19 "config_field_values": [
20 {
21 "config_field_id": "input",
22 "value": "query {\n order {\n lineItems {\n quantity\n originalUnitPriceSet {\n shopMoney {\n amount\n }\n }\n product {\n tags\n }\n }\n }\n}"
23 },
24 {
25 "config_field_id": "script",
26 "value": "export default function main(input) {\n const fragileTotal = input.order.lineItems\n .filter(item => item.product?.tags.some(tag => tag.toLowerCase() === \"fragile\"))\n .reduce((total, item) => total + item.quantity * Number(item.originalUnitPriceSet.shopMoney.amount), 0);\n return { fragileTotal };\n}"
27 },
28 {
29 "config_field_id": "output_schema",
30 "value": "type Output {\n fragileTotal: Float!\n}"
31 }
32 ]
33 },
34 {
35 "step_id": "has_high_value_fragile_items",
36 "task_id": "shopify::flow::condition",
37 "task_version": "0.1",
38 "task_type": "CONDITION",
39 "config_field_values": [
40 {
41 "config_field_id": "condition",
42 "value": "(runCode.fragileTotal > 200)"
43 }
44 ]
45 },
46 {
47 "step_id": "email_fragile_order",
48 "task_id": "shopify::flow::send_email",
49 "task_version": "2.0",
50 "task_type": "ACTION",
51 "config_field_values": [
52 {
53 "config_field_id": "address",
54 "value": "staff@example.com"
55 },
56 {
57 "config_field_id": "subject",
58 "value": "High-value fragile shipment {{ order.name }}"
59 },
60 {
61 "config_field_id": "message",
62 "value": "The original total for fragile-tagged items in order {{ order.name }} is {{ runCode.fragileTotal }} {{ order.currencyCode }}."
63 }
64 ]
65 }
66 ],
67 "links": [
68 {
69 "from_step_id": "order_created",
70 "from_port_id": "output",
71 "to_step_id": "total_fragile_items",
72 "to_port_id": "input"
73 },
74 {
75 "from_step_id": "total_fragile_items",
76 "from_port_id": "output",
77 "to_step_id": "has_high_value_fragile_items",
78 "to_port_id": "input"
79 },
80 {
81 "from_step_id": "has_high_value_fragile_items",
82 "from_port_id": "true",
83 "to_step_id": "email_fragile_order",
84 "to_port_id": "input"
85 }
86 ],
87 "patched_fields": []
88 }
89}