[ { "label": "Promote and demote products based on inventory threshold", "trigger_type": [ "product_updated" ], "object_type": "product", "app_id": "triggers", "settings": { "priority": 0, "condition_groups": { "1": { "conditions": { "1": { "field": "product.twig_condition", "settings": { "title": "Inventory over x", "value": "{% set threshold = 1 %}\r\n{% set in_stock = 0 %}\r\n{% for product_variant in product.variants %}\r\n {% if product_variant.inventory_quantity > 0 %}\r\n {% set in_stock = in_stock | plus (1) %}\r\n {% endif %}\r\n{% endfor %}\r\n{% if in_stock >= threshold %}\r\ntrue\r\n{% endif %}", "token_browser": "{{ Browse Tokens }}", "condition_type": "AND" }, "weight": 999 } }, "actions": { "1": { "type": "product_sync_tags", "settings": { "wait": "0", "custom_wait": "", "tags": "promote" }, "weight": 999, "target_key": "product" } } }, "2": { "conditions": { "1": { "field": "product.twig_condition", "settings": { "title": "inventory under x", "value": "{% set threshold = 0 %}\r\n{% set in_stock = 0 %}\r\n{% for product_variant in product.variants %}\r\n {% if product_variant.inventory_quantity > 0 %}\r\n {% set in_stock = in_stock | plus (1) %}\r\n {% endif %}\r\n{% endfor %}\r\n{% if in_stock <= threshold %}\r\ntrue\r\n{% endif %}", "token_browser": "{{ Browse Tokens }}", "condition_type": "AND" }, "weight": 999 } }, "actions": { "1": { "type": "product_sync_tags", "settings": { "wait": "0", "custom_wait": "", "tags": "demote" }, "weight": 999, "target_key": "product" } } } }, "shared_workflow_id": 9431 }, "description": "Synchronize product tags based on inventory levels. This automation is fired when a product is updated, it checks for the current inventory level and then adds or removes the tags based on the available quantities. " } ]