[ { "label": "Transfer draft order metafields to order metafields", "trigger_type": [ "draft_order_updated" ], "object_type": "draft_order", "app_id": "triggers", "settings": { "condition_groups": { "1": { "conditions": { "1": { "field": "draft_order.order_id", "settings": { "operator": "not_empty", "value": "", "token_browser": "{{ Browse Tokens }}", "token_object_type": "draft_order", "condition_type": "AND" }, "weight": 999 } }, "actions": { "3": { "type": "shopify_api_request", "settings": { "wait": "0", "custom_wait": "", "label": "get existing order metafields", "method": "GET", "path": "orders\/{{ draft_order.order_id }}\/metafields", "data": "", "response_handle": "handle_response", "response_object_type": "", "parent_data": "", "workflow_actions": [], "token_object_type": "draft_order", "exported_workflow": { "label": "HTTP Response subworkflow", "trigger_type": [ "manual" ], "object_type": "http_response", "app_id": "triggers", "settings": { "condition_groups": { "1": { "conditions": [], "actions": { "1": { "type": "shopify_api_request", "settings": { "wait": "0", "custom_wait": "", "label": "add or update order metafields with draft order metafields", "method": "PUT", "path": "orders\/{{ parent.order_id }}", "data": "{% set metas = [] %}\r\n{% for info in parent.metafields %}\r\n {% for key, meta in info %}\r\n {% set id = '' %} \r\n {% for existing_meta in http_response.json.metafields %}\r\n {% if (existing_meta.namespace == meta.namespace) and (existing_meta.key == meta.key) %}\r\n {% set id = existing_meta.id %}\r\n {% endif %} \r\n {% endfor %}\r\n \r\n {% set metas = metas|merge([{\r\n namespace: meta.namespace, \r\n key: meta.key, \r\n value: meta.value, \r\n value_type: meta.value_type, \r\n id: id \r\n }]) \r\n %}\r\n {% endfor %}\r\n{% endfor %}\r\n{\r\n \"order\": {\r\n \"id\": {{ parent.order_id }},\r\n \"metafields\": {{ metas | to_json }}\r\n }\r\n}", "response_handle": "", "response_object_type": "", "parent_data": "", "workflow_actions": [], "token_object_type": "http_response" }, "weight": 999, "target_key": "http_response" } } } } } } }, "weight": 1019, "target_key": "draft_order" } } } }, "shared_workflow_id": 22238 } } ]