[ { "label": "Email customer after purchasing a specific product based on custom field values", "trigger_type": [ "order_paid" ], "object_type": "order", "app_id": "triggers", "settings": { "priority": 0, "condition_groups": [ { "conditions": [ { "field": "order.email", "settings": { "operator": "not_empty", "value": "Custom\r\n", "long_value": "Custom\r\n", "token_browser": "{{ Browse Tokens }}", "token_object_type": "order", "condition_type": "AND" }, "weight": 999 } ], "actions": { "1": { "type": "custom", "settings": { "wait": "0", "custom_wait": "", "label": "", "twig": "{% set message = \"Follow up \\n\" %}\r\n\r\n{% for line_item in order.line_items %}\r\n\r\n{% set product_meta = RUN_ACTION('shopify_api_request',{\r\n method: \"GET\",\r\n path: \"products\/\"~line_item.product_id~\"\/metafields\",\r\n data: {limit: 5} \r\n }) %}\r\n \r\n {% if product_meta.response.metafields is defined %}\r\n {% for meta in product_meta.response.metafields if meta.namespace=='custom_fields' and meta.key=='custom_link' %}\r\n {% set message = message~meta.value~\"\\n\" %}\r\n {% endfor %}\r\n {% endif %}\r\n \r\n{% endfor %}\r\n\r\n{% set email_to = order.email %}\r\n{% if not message!=\"Follow up \\n\" %}\r\n {% do QUEUE_ACTION('email',{\r\n to: email_to,\r\n subject: \"Follow Up on Items purchased!\",\r\n body: message,\r\n plain_text: false,\r\n context: {order: order}\r\n \r\n }) %}\r\n{% endif%}\r\n", "token_object_type": "order" }, "weight": 999, "target_key": "order" } } } ], "shared_workflow_id": 33217 }, "description": "This workflow is fired when an order is raised. The automation will send a follow-up email with product custom field values depending on the items they purchased. " } ]