Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
Hi,
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.
This was getting very close: community.shopify.com/c/shopify-flow-app/checking-skus-in-a-customers-previous-orders/td-p/2328679, but the person stopped replying before @paul_n was able to finish helping out.
Any ideas the next step in the flow to count only the line items that match SKU ABC?
Hello @Chegism
I am assuming you want your customer to buy 1 unique SKU per order, but they can order multiple different SKU per order, am I right?
Correct. They can also place multiple different orders - but we want to auto-cancel if the order the same SKU a second time.
Where are you trying to do that count? I'm assuming your workflow looks like:
Order Created
Get Order Data: created_at:>'{{ "now" | date_minus: "24 hours" }}' AND customer_id {{order.customer.legacyResourceID}} AND sku: ABC
But it isn't counting the SKU I'm adding at all, it's being ignored (i.e. placing a new order for a completely different SKU is still triggering it)
Are you using lowercase sku? It works ok in my store:
No, I was using uppercase as that's what was listed for the SKU back on the product page.
Does only lowercase work, and does it need to be wrapped in ""?
It is usually safe to wrap and helpful when it can have spaces.
The doc for what query variables are available is here:
https://shopify.dev/docs/api/admin-graphql/2024-01/objects/QueryRoot#connection-orders (you'll have to expand it a couple of times)
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
I have this now.
Order Created
Get Order Data (this code, changing customer_id to customer)
Count items in getOrderData
Check if Count is greater than or equal to 2
It's firing on every single order that comes in, even customers with 1 order for a different SKU.
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.
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.
I think I need to see an image of your workflow because something isn't set up correctly
Looks right. You might need to share the link of the workflow so we can look closer. You can either go through support to share that or DM me here.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024