[ { "label": "Tag a Product if it has Sold More than X Times in the Current Week", "trigger_type": [ "order_paid" ], "object_type": "order", "app_id": "triggers", "settings": { "priority": 0, "condition_groups": [ { "conditions": [], "actions": [ { "type": "trigger_child_workflow", "settings": { "token_object_type": "order", "target_path": "order.line_items", "wait": "0", "cw_timezone": "America\/Los_Angeles", "custom_wait": "", "run_once": 0, "exported_workflow": { "label": "Line Item subworkflow", "trigger_type": [ "line_item_custom" ], "object_type": "line_item", "app_id": "triggers", "settings": { "priority": 0, "condition_groups": [ { "conditions": [], "actions": [ { "type": "database_key_value", "settings": { "wait": "0", "custom_wait": "", "resource_type": "products", "resource_id": "{{ line_item.product_id }}", "key": "sold_in_week_{{ \"now\" | date(\"W_Y\") }}", "value": "{% set key = \"sold_in_week_\" ~ \"now\" | date(\"W_Y\") %}\r\n{{ line_item.product.database[key] + line_item.quantity }}" }, "weight": 999, "target_key": "line_item" } ] }, { "conditions": [ { "field": "line_item.product.database", "settings": { "multiple": "any", "key": "sold_in_week_{{ \"now\" | date(\"W_Y\") }}", "operator": "gt", "value": "10", "token_browser": "{{ Browse Tokens }}", "condition_type": "AND" }, "weight": 999 } ], "actions": [ { "type": "product_sync_tags", "settings": { "wait": "0", "custom_wait": "", "tags": "HOT_THIS_WEEK" }, "weight": 999, "target_key": "line_item.product" } ] } ] } } }, "weight": 999, "target_key": "order" } ] } ], "shared_workflow_id": 2860 }, "description": "This automation is fired every time an item is sold; it checks for the number of times is has been sold in the current week, compares it to the set threshold, and if it meets the threshold, adds a \"hot_this_week\" tag. " } ]