Advanced return abuse detection
Tracks processed returns in a rolling window and tags customers who cross configurable abuse thresholds.
Setup guide
Before you start
This template watches approved returns and keeps a rolling abuse history on each customer.
How it works
- Trigger:
returns/approve - Each approved return is added to a rolling history stored in a customer metafield
- The workflow totals return count and returned value over the configured window
- If both thresholds are crossed, it tags the customer and can optionally tag the triggering order
- Compare-digest metafield writes are used so concurrent return approvals do not overwrite each other
Configure in setup
Return count threshold: number of approved returns required inside the rolling windowReturn value threshold: total approved returned value required inside the rolling windowRolling window days: how many days of return history to keepCustomer risk tag: customer tag applied when thresholds are crossedOrder risk tag: optional order tag applied to the triggering order; leave blank to disableMetafield namespaceandMetafield key: where the compact JSON history is stored on the customer
Notes
- This template is intended for operational review and risk flagging, not automatic enforcement
- The stored state lives on the customer, so the history moves with the customer record inside Shopify
Setup fields
Number of approved returns inside the rolling window required before the customer is flagged.
Total approved returned value in shop currency required before the customer is flagged.
How many days of approved return history are kept for threshold evaluation.
Customer tag applied when the configured thresholds are crossed.
Optional order tag applied to the triggering order when thresholds are crossed. Leave blank to disable order tagging.
Namespace used for the customer metafield that stores the rolling return history JSON.
Metafield key used for the customer state JSON.