[ { "label": "Set sizescale fullness as a tag", "trigger_type": [ "product_created", "product_updated" ], "object_type": "product", "app_id": "triggers", "settings": { "priority": 0, "condition_groups": { "1": { "conditions": [], "actions": { "3": { "type": "step", "settings": [], "weight": 10, "target_key": null }, "2": { "type": "product_remove_tags", "settings": { "token_object_type": "product", "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 %}", "wait": "0", "cw_timezone": "America\/Phoenix", "custom_wait": "" }, "weight": 20, "target_key": "product" }, "4": { "type": "step", "settings": [], "weight": 30, "target_key": null }, "1": { "type": "product_add_tags", "settings": { "token_object_type": "product", "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", "wait": "0", "cw_timezone": "America\/Phoenix", "custom_wait": "" }, "weight": 40, "target_key": "product" } } } }, "shared_workflow_id": 8875 }, "description": "This automation is fired when a product is created or updated. The workflow checks for the ratio of variants in stock versus the item of stock variants and tags the product with the ratio as a percentage." } ]