[ { "label": "Tag & Untag Best Selling Products Within A Two Week Window", "trigger_type": [ "order_created" ], "object_type": "order", "app_id": "triggers", "settings": { "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": { "condition_groups": [ { "conditions": [], "actions": { "0": { "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 }}", "token_object_type": "line_item" }, "weight": 999, "target_key": "line_item" }, "2": { "type": "debug", "settings": { "wait": "0", "custom_wait": "", "action_label": "Custom Condition Tracking", "title": "Log Custom Conditions", "body": "{{ line_item.title }}: {{ line_item.variant_title }}\r\n{{ line_item.product.admin_url }}\r\n{% set last_week_key = \"sold_in_week_\" ~ now | date_modify(\"-7 days\") | date(\"W_Y\") %}\r\n{% set last_week_count = line_item.product.database[last_week_key] %}\r\nLast Week Key: {{ last_week_key }}\r\nLast Week Count: {{ last_week_count }}\r\n{% set this_week_key = \"sold_in_week_\" ~ now | date(\"W_Y\") %}\r\n{% set this_week_count = line_item.product.database[this_week_key] %}\r\nThis Week Key: {{ this_week_key }}\r\nThis Week Count: {{ this_week_count }}\r\n{% set total = this_week_count + last_week_count %}\r\nTotal: {{ total }}\r\n{% if total >= threshold %}\r\ntrue\r\n{% else %}\r\nfalse\r\n{% endif %}", "token_object_type": "line_item" }, "weight": 1019, "target_key": "line_item" } } }, { "conditions": { "1": { "field": "line_item.twig_condition", "settings": { "title": "", "value": "{% set threshold = 3 %}\r\n{% set last_week_key = \"sold_in_week_\" ~ now | date_modify(\"-7 days\") | date(\"W_Y\") %}\r\n{% set last_week_count = line_item.product.database[last_week_key] %}\r\n{% set this_week_key = \"sold_in_week_\" ~ now | date(\"W_Y\") %}\r\n{% set this_week_count = line_item.product.database[this_week_key] %}\r\n{% set total = this_week_count + last_week_count %}\r\n{% if total >= threshold %}\r\ntrue\r\n{% endif %}", "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": "Best Seller", "token_object_type": "line_item" }, "weight": 999, "target_key": "line_item.product" } ] } ] } } }, "weight": 999, "target_key": "order" } ] } ], "shared_workflow_id": 16113 } } ]