[ { "label": "HOT TODAY TAG \ud83d\udd25 Tag a Product if it has Sold More than X Times in the Current Week", "trigger_type": [ "order_created" ], "object_type": "order", "app_id": "triggers", "settings": { "priority": 0, "condition_groups": [ { "conditions": [], "actions": [ { "type": "trigger_child_workflow", "settings": { "target_path": "order.line_items", "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_day_{{ \"now\" | date(\"W_Y\") }}", "value": "{% set key = \"sold_in_day_\" ~ \"now\" | date(\"W_Y\") %}\r\n{{ line_item.product.database[key] + line_item.quantity }}", "token_object_type": "line_item" }, "weight": 999, "target_key": "line_item" } ] }, { "conditions": [ { "field": "line_item.product.database", "settings": { "multiple": "any", "key": "sold_in_day_{{ \"now\" | date(\"W_Y\") }}", "operator": "gt", "value": "0", "token_browser": "{{ Browse Tokens }}", "token_object_type": "line_item", "condition_type": "AND" }, "weight": 999 } ], "actions": [ { "type": "product_sync_tags", "settings": { "wait": "0", "custom_wait": "", "tags": "HOT TODAY", "token_object_type": "line_item" }, "weight": 999, "target_key": "line_item.product" } ] } ] } } }, "weight": 999, "target_key": "order" } ] } ], "shared_workflow_id": 14745 }, "description": "This automation is fired when a product is sold. The workflow checks how many times the product has been sold in the current week and if the quantity is above the pre-defined level. It tags the product with \"HOT TODAY \ud83d\udd25\"" } ]