We’re battling customers trying to get around our sale limits of 1 per SKU by placing multiple orders.
I’m trying to use Flow to automatically cancel an order if they place a second order within 24 hours containing the same SKU.
i.e.
Order 1 SKU ABC x1 goes through
Order 2 SKU BDC x1 goes through
Order 3 SKU ABC x1 Auto-Canceled
I’m able to get a count of the customers orders placed within the last 24 hours. I can even action that based on how many orders they have placed.
But when I try to filter it down to SKU all I’m getting is a count of ALL SKUs across all orders in that 24 hour time period. Not just SKU ABC.
FYI, you also appear to be missing a colon and using the wrong variable for customer (customer_id and ResourceID both wrong). Try:
customer:{{order.customer.legacyResourceId}}
Full query:
created_at:>'{{ "now" | date_minus: "24 hours" }}' AND customer:{{order.customer.legacyResourceId}} AND sku:ABC
By firing, I’m assuming you mean that runs for every order, which is how Order created works.
If you want that logic to only execute for when the SKU is present in the current order, add a condition before the “Get order data” to check the current sku. (if at least one of order/lineItems/sku == YOURSKU)
By firing I actually meant the end result of canceling the order. In my testing I have it set to send an internal email instead as that doesn’t affect the customers.
Order Created
Get Order Data (created_at:>‘{{ “now” | date_minus: “24 hours” }}’ AND customer:{{order.customer.legacyResourceId}} AND sku:ABC)
Count items in getOrderData
Check if Count is greater than or equal to 2
Send Internal Email
Expected: If a customer places 1 order for SKU ABC, nothing happens. If a customer places 1 order for SKU EFG, nothing happens. If a customer places a second order for SKU ABC, send internal email.
What is happening: If a customer places 1 order for SKU ABC, send internal email.. If a customer places 1 order for SKU EFG, send internal email. If a customer places a second order for SKU ABC, send internal email.
I have added your suggestion to do a Check if SKU includes ABC before Get Order Data, which has worked to remove someone purchasing a completely different SKU from the flow. But the check if count of 2+ isn’t working and it’s still sending that email on the very first order.