[ { "label": "Tag a product based the location where it's stocked", "trigger_type": [ "product_updated", "product_created" ], "object_type": "product", "app_id": "triggers", "settings": { "priority": 0, "condition_groups": { "1": { "conditions": [], "actions": { "1": { "type": "custom", "settings": { "wait": "0", "custom_wait": "", "label": "", "twig": "{% set tags_to_add = [] %}\r\n{% set tags_to_remove = [] %}\r\n{% for location in shop.locations %}\r\n {% if product.inventory_quantity_by_location[location.id] > 0 %}\r\n {% set tags_to_add= tags_to_add|merge([location.name]) %}\r\n {% else %}\r\n {% set tags_to_remove= tags_to_remove|merge([location.name]) %}\r\n {% endif %}\r\n{% endfor %}\r\n{%\r\nset response = QUEUE_ACTION('product_add_remove_tags',{\r\n resource: product,\r\n add_tags: tags_to_add,\r\n remove_tags:tags_to_remove\r\n})\r\n%}", "token_object_type": "product" }, "weight": 999, "target_key": "product" } } } }, "shared_workflow_id": 33861 }, "description": "This automation tags products based on where they are stocked. The location tags are also removed once the product runs out of stock" } ]