[ { "label": "Set sizescale fullness as a tag", "trigger_type": [ "product_created", "product_updated" ], "object_type": "product", "app_id": "triggers", "settings": { "condition_groups": { "1": { "conditions": [], "actions": { "3": { "type": "step", "settings": [], "weight": 10, "target_key": null }, "2": { "type": "product_remove_tags", "settings": { "wait": "0", "custom_wait": "", "check_date": [], "tags": "{# Removes any sizescale tag, tag will be added back if it didn't change. #}\r\n{% for product_tag in product.tags_array %}\r\n {% if \"sizescale_full\" in product_tag.getValue() %}\r\n {{ product_tag }}\r\n {% endif %}\r\n{% endfor %}" }, "weight": 20, "target_key": "product" }, "4": { "type": "step", "settings": [], "weight": 30, "target_key": null }, "1": { "type": "product_add_tags", "settings": { "wait": "0", "custom_wait": "", "check_date": [], "tags": "{% set count = product.variants | length %}\r\n{% set with_inventory = 0%}\r\n\r\n{% for product_variant in product.variants %}\r\n {% if product_variant.inventory_quantity > 0 %}\r\n {% set with_inventory = with_inventory | plus(1) %}\r\n {% endif %}\r\n{% endfor %}\r\n{% set percent = (count | minus(with_inventory)) | divided_by(count)| times(100) %}\r\n{{ 100 | minus(percent) }}% sizescale_full" }, "weight": 40, "target_key": "product" } } } }, "shared_workflow_id": 8875 } } ]