How to detect a potential return abuser in customer orders?

Solved

How to detect a potential return abuser in customer orders?

KWILSON117
Shopify Partner
2 0 0

Hi there! Does anyone have any flows worked on that can check if a customer appears to be a Return Abuser? I am having issues trying to figure out how to notify myself on customer's that have placed 3 or more orders where the net sales are less than $150 to try to see who routinely returns their order so that I can work on blocking them as a future customer. I've looked into the Fraud Filter app but it doesn't look like it can do the checks I want. I've touched based with Shopify Support and it also doesn't appear that the Flow app can check all orders in history so I'm at a bit of a loss as what to try next. Any advice or suggestions would be greatly appreciated! 

Accepted Solution (1)

DaveMcV
Shopify Staff
104 31 29

This is an accepted solution.

Hi KWILSON117,

So there's a couple of ways which Flow could be useful depending on your exact use case. The criteria you mentioned (3 or more orders and less than $150) can be modelled in flow as shown in the screenshot below by looking at the order.customer.numberOfOrders and order.customer.amountSpent.amount fields that come from an Order created trigger. This will include the current order as well as all previous orders, so if they are returning their order the current order may put them over the $150 threshold.

Screenshot 2024-03-01 at 4.45.50 PM.png

If your goal is to create a notification when a customer who previous had a return creates a new order, something more like the following workflow may be better. The workflow will fetch all previous orders from the customer that are in some state of a return, count how many there were and then check if that number is greater than zero before sending a notification.

To do this, you'll want to use the following query in the Get order data step's Advanced query mode and ensure you set the Maximum number of orders to 100.

customer_id:{{order.customer.legacyResourceId}} AND return_status:"return_requested,in_progress,returned"


Screenshot 2024-03-01 at 5.00.01 PM.png

Hope that helps!

DaveMcV | Flow Development Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.

View solution in original post

Replies 5 (5)

DaveMcV
Shopify Staff
104 31 29

This is an accepted solution.

Hi KWILSON117,

So there's a couple of ways which Flow could be useful depending on your exact use case. The criteria you mentioned (3 or more orders and less than $150) can be modelled in flow as shown in the screenshot below by looking at the order.customer.numberOfOrders and order.customer.amountSpent.amount fields that come from an Order created trigger. This will include the current order as well as all previous orders, so if they are returning their order the current order may put them over the $150 threshold.

Screenshot 2024-03-01 at 4.45.50 PM.png

If your goal is to create a notification when a customer who previous had a return creates a new order, something more like the following workflow may be better. The workflow will fetch all previous orders from the customer that are in some state of a return, count how many there were and then check if that number is greater than zero before sending a notification.

To do this, you'll want to use the following query in the Get order data step's Advanced query mode and ensure you set the Maximum number of orders to 100.

customer_id:{{order.customer.legacyResourceId}} AND return_status:"return_requested,in_progress,returned"


Screenshot 2024-03-01 at 5.00.01 PM.png

Hope that helps!

DaveMcV | Flow Development Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
mattsirkin
Excursionist
17 0 49

Thank you so much for this answer! I also had this question! 

 

Is it possible to modify this to count the number of returned items (instead of returned orders) for the customer? For example, I have customers that will order multiple items in a single order and return some of them, and I would like to count how many they have returned overall vs how many they have kept. Thanks!

KWILSON117
Shopify Partner
2 0 0

That would be amazing to track as well!!

DaveMcV
Shopify Staff
104 31 29

Hi Mattsirkin,

 

You can do that, but you'll need to use the Run Code action to sum all the quantities across all the Orders. Here's an updated example:

DaveMcV_0-1710430982058.png

With the following Run Code step setup:

DaveMcV_1-1710431004975.png

 

Input Query:

query{
  getOrderData {
    returns {
      totalQuantity
      returnLineItems {
        quantity
      }
    }
  }
}

 

Output type:

"The output of Run Code"
type Output {
  "The total number of items returned by this buyer"
  totalReturnedItems: Int!
}

And the code itself:

export default function main(input) {
  // Make sure that the data you return matches the
  // shape & types defined in the output schema.

  let totalReturnedItems = 0;
  input.getOrderData.forEach((order) => {
    order.returns.forEach((returnItem) => {
      totalReturnedItems += returnItem.totalQuantity;
    });
  });
  return {
    totalReturnedItems,
  }
}

 

Hope that helps!

DaveMcV | Flow Development Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
mattsirkin
Excursionist
17 0 49

Thank you so much!