[ { "label": "Cancel Duplicate Orders Within 24 hours", "trigger_type": [ "order_created" ], "object_type": "order", "app_id": "triggers", "settings": { "priority": 0, "condition_groups": { "1": { "conditions": [], "actions": { "1": { "type": "shopify_api_request", "settings": { "wait": "0", "custom_wait": "", "label": "", "method": "GET", "path": "customers\/{{ order.customer.id }}\/orders", "data": "{# \r\nOnly consider a totla of 5 items at a time. \r\nThe current order will be included in the 5, \r\nbut discarded during subworkflow processing \r\nso this gets us to 4. \r\n\r\nAdditonally, this will only get orders created \r\nbefore this order, and must be within 1 day of \r\nthis order, with a status of open.\r\n#}\r\n\r\n{\r\n\"limit\": 5,\r\n\"created_at_min\": \"{{ now|date_modify('-1 day')|date('c') }}\",\r\n\"created_at_max\": \"{{ order.created_at }}\",\r\n\"status\": \"open\"\r\n}", "response_handle": "handle_objects", "response_object_type": "order", "parent_data": "", "workflow_actions": [], "token_object_type": "order", "exported_workflow": { "label": "Order subworkflow", "trigger_type": [ "manual" ], "object_type": "order", "app_id": "triggers", "settings": { "priority": 0, "condition_groups": { "1": { "conditions": { "1": { "field": "order.twig_condition", "settings": { "title": "", "value": "{% if order.id and parent.total_price == order.total_price and parent.id != order.id %}\r\ntrue\r\n{% endif %}", "token_browser": "{{ Browse Tokens }}", "token_object_type": "order", "condition_type": "AND" }, "weight": 999 } }, "actions": { "2": { "type": "order_cancel", "settings": { "wait": "0", "custom_wait": "", "reason": "other", "restock": 1, "notify_customer": 0, "token_object_type": "order" }, "weight": 1009, "target_key": "order" }, "3": { "type": "order_refund", "settings": { "wait": "0", "custom_wait": "", "currency": "{{ shop.currency }}", "note": "Duplicate order {{ order.order_number }}\r\n\r\n{{ shopify_admin_link(order, {resource: 'orders', format: 'html', title: null}) }}", "restock_type": "cancel", "refund_shipping": 1, "notify_customer": 0, "token_object_type": "order" }, "weight": 1019, "target_key": "order" }, "4": { "type": "order_add_note", "settings": { "wait": "0", "custom_wait": "", "note": "Cancelled due to duplicate order matching criteria in an Arigato Automation workflow. ", "token_object_type": "order" }, "weight": 1029, "target_key": "order" }, "5": { "type": "debug", "settings": { "wait": "0", "custom_wait": "", "action_label": "", "title": "", "body": "Cancelling because the following conditions were met\r\nParent price: {{ parent.total_price }}\r\nOrder price: {{ order.total_price }} \r\nParent id: {{ parent.id }} \r\nOrder id {{ order.id }}", "token_object_type": "order" }, "weight": 1039, "target_key": "order" } } } } } } }, "weight": 999, "target_key": "order" } } } }, "shared_workflow_id": 15561 }, "description": "This automation fires every time an order is raised. It checks to see if the customer has raised a similar order in the last 24 hours and if one exists. It cancels the current order. " } ]