[ { "label": "Tag product based on collection metafields", "trigger_type": [ "collection_custom" ], "object_type": "collection", "app_id": "triggers", "settings": { "priority": 0, "condition_groups": { "1": { "conditions": [], "actions": { "3": { "type": "step", "settings": [], "weight": -10, "target_key": null }, "1": { "type": "custom", "settings": { "wait": "0", "custom_wait": "", "label": "", "twig": "{% set meta = RUN_ACTION('shopify_api_request',{\r\n method: \"GET\",\r\n path: \"collections\/\"~collection.id~\"\/metafields\"\r\n})%}\r\n{% set metas = meta.response.metafields %}\r\n{% set to_tag = 0 %}\r\n{% set tag = false %}\r\n\r\n{% for meta in metas if meta.namespace=='category' and meta.key=='display_search' %}\r\n{% if meta.value == 'TRUE' %}\r\n{% set to_tag = 1 %}\r\n{% endif %}\r\n{% endfor %}\r\n{% for meta in metas if meta.namespace=='category' and meta.key=='web_hierarchy' %}\r\n{% set tag = meta.value %}\r\n{% endfor %}\r\n\r\n{% set db_val = RUN_ACTION('set_database',{\r\n key: \"to_tag_\"~collection.id,\r\n value: to_tag\r\n})\r\n%}\r\n{% set db_val = RUN_ACTION('set_database',{\r\n key: \"tag_\"~collection.id,\r\n value: tag\r\n})\r\n%}", "token_object_type": "collection" }, "weight": 999, "target_key": "collection" }, "4": { "type": "step", "settings": [], "weight": 1008, "target_key": null }, "2": { "type": "shopify_api_request", "settings": { "wait": "0", "run_once": 0, "custom_wait": "", "label": "", "method": "GET", "path": "collections\/{{ collection.id }}\/products", "data": "", "response_handle": "handle_objects", "response_object_type": "product", "parent_data": "", "workflow_actions": [], "token_object_type": "collection", "exported_workflow": { "label": "Product subworkflow", "trigger_type": [ "manual" ], "object_type": "product", "app_id": "triggers", "settings": { "priority": 0, "condition_groups": { "1": { "conditions": { "2": { "field": "product.twig_condition", "settings": { "title": "", "value": "{% set key = \"to_tag_\"~parent.id %}\r\n{% if shop.database[key]==\"1\" %}\r\ntrue\r\n{% endif%}", "token_object_type": "product", "condition_type": "AND" }, "weight": 10 }, "1": { "field": "product.tags_array", "settings": { "multiple": "none", "operator": "equals", "value": "{% set key = \"tag_\"~parent.id %}\r\nCategory: {{shop.database[key] }}", "long_value": "Category: {{shop.database.tag}}_{{ parent.id }}", "token_object_type": "product", "condition_type": "AND" }, "weight": 20 } }, "actions": { "1": { "type": "product_add_tags", "settings": { "wait": "0", "custom_wait": "", "tags": "{% set key = \"tag_\"~parent.id %}\r\nCategory: {{shop.database[key] }}", "token_object_type": "product" }, "weight": 30, "target_key": "product" } } }, "2": { "conditions": { "1": { "field": "product.twig_condition", "settings": { "title": "", "value": "{% set key = \"to_tag_\"~parent.id %}\r\n{% shop.database[key]==0 %}\r\ntrue\r\n{% endif%}", "token_object_type": "product", "condition_type": "AND" }, "weight": 10 }, "2": { "field": "product.tags_array", "settings": { "multiple": "any", "operator": "equals", "value": "{% set key = \"tag_\"~parent.id %}\r\nCategory: {{shop.database[key]}}", "long_value": "Category: {{ parent.database.tag }}", "token_object_type": "product", "condition_type": "AND" }, "weight": 20 } }, "actions": { "1": { "type": "product_remove_tags", "settings": { "wait": "0", "custom_wait": "", "tags": "{% set key = \"tag_\"~parent.id %}\r\nCategory: {{shop.database[key]}}", "token_object_type": "product" }, "weight": 999, "target_key": "product" } } }, "3": { "conditions": [], "actions": { "1": { "type": "debug", "settings": { "wait": "0", "custom_wait": "", "action_label": "", "title": "", "body": "{% set key = \"tag_\"~parent.id %}\r\nCategory: {{shop.database[key]}}", "token_object_type": "product" }, "weight": 999, "target_key": "product" } } } } } } }, "weight": 1009, "target_key": "collection" } } } }, "shared_workflow_id": 46431 }, "description": "Thsi workflow will transfer collection metafields to product tags on collection update." } ]