[ { "label": "Add a tag for each collection a product is in", "trigger_type": [ "product_created", "product_updated" ], "object_type": "product", "app_id": "triggers", "settings": { "priority": 0, "condition_groups": [ { "conditions": [], "actions": [ { "type": "product_add_tags", "settings": { "wait": "0", "custom_wait": "", "tags": "{{ product.collections | join(',') }}", "token_object_type": "product" }, "weight": 999, "target_key": "product" }, { "type": "product_remove_tags", "settings": { "wait": "0", "custom_wait": "", "tags": "{% set tags_to_remove = [] %}\r\n{% for product_tag in product.tags_array %}\r\n {% set remove=true %}\r\n {% for collection in product.collections %}\r\n {% if collection == product_tag %}\r\n {% set remove=false %}\r\n {% endif%}\r\n {% endfor %}\r\n {% if remove==true %}\r\n {% set tags_to_remove = tags_to_remove|merge([product_tag]) %}\r\n {% endif %}\r\n \r\n{% endfor %}\r\n{{tags_to_remove|join(',')}}", "token_object_type": "product" }, "weight": 1009, "target_key": "product" } ] } ], "shared_workflow_id": 1340 }, "description": "This workflow runs when a product is created or updated. It will add a tag for each collection, and remove those tags if a product is removed from a collection. This workflow does not require any changes to run correctly, and is a good example of custom coding in the app." } ]