Automatic cod-refused tagging with Shopify Flow

Updated · 6 min read · Trifid Media LLC

Yes, Shopify Flow can tag COD refusers for you. Build a workflow that starts with the Order canceled trigger, checks that the order's payment gateway names include "Cash on Delivery", and runs Add customer tags with cod-refused. Before you rely on it, test it on a cancelled order that had already shipped: Shopify's help describes this trigger for unfulfilled orders, and a refused parcel has usually been fulfilled before it comes back.

What is Shopify Flow?

Shopify Flow is Shopify's own automation app. A workflow has three kinds of steps:

  • a trigger, the event that starts it (each workflow has only one)
  • conditions, checks that decide whether it carries on
  • actions, the changes it makes, such as adding a tag

Shopify says Flow is a free app available on the Basic, Grow, Advanced and Plus plans. You install it from the Shopify App Store, then open it from Apps > Flow in your admin.

Why tag refusers automatically?

A cod-refused tag on a customer lets a COD rule hide Cash on Delivery for them next time, while they can still pay online. Tagging by hand works, but it is easy to forget on a busy day. A workflow tags the customer as soon as you cancel the order.

Khaleeji COD hides COD for customers tagged cod-refused or cod-blocked, so a tag added by Flow works with it. Any other tool you use must read the same tag name.

How do you build the workflow?

  1. From your Shopify admin, go to Apps > Flow.
  2. Click Create workflow.
  3. Click Select a trigger and choose Order canceled.
  4. Click +, then Condition. Choose the order's payment gateway names field (paymentGatewayNames in Shopify's API, a list of the gateways used on the order). Set it to At least one of the names Includes Cash on Delivery.
  5. On the True branch, click + > Action and choose Add customer tags. Enter cod-refused.
  6. Give the workflow a clear name, such as "Tag COD refusers".
  7. Don't turn it on yet. Test it first, as below.

A few details matter here:

  • The COD name. Shopify's built-in method is called "Cash on Delivery (COD)". "Includes Cash on Delivery" matches it and custom names that contain the same words. Flow compares text without caring about upper or lower case. If your COD method has a different name, such as an Arabic one, add it as a second criterion in the same condition and combine the two with OR.
  • Check the real value. The test below shows what Flow sees in the payment gateway field for a past order, so you can copy the exact text.
  • The customer. The action tags the customer linked to the order. Flow fills in the customer for you.

How do you test it before it tags real customers?

  1. In the workflow editor, click Test your workflow at the trigger. Choose + Add event > Create event and pick a past cancelled COD order. Flow highlights the path the order would take, and the Preview tab shows the data at each step. Shopify says a test run stops at the first action that would change something, so no tag is added.
  2. Test a cancelled order that wasn't paid by COD the same way. It should stop at the condition.
  3. For the live test, change the action's tag to a holding tag such as cod-review, one your COD rule doesn't read, and click Turn on workflow.
  4. Place a test COD order with your own email address, fulfill it as you would before handing it to a courier, then cancel it the way you cancel a refused order. Shopify notes that cancelling issues a full refund, so never test on a real customer's paid order.
  5. Open the workflow's Recent runs and the test customer's profile. If the run and the tag are there, remove the tag and change the action back to cod-refused. If there is no run, read the next section.

Test runs from step 1 don't appear in Recent runs, so a missing entry for them is normal.

Does the trigger run for orders that had already shipped?

That is what step 4 checks. Shopify's Flow help says the Order canceled trigger starts a workflow when someone in your team, or an app, cancels an unfulfilled order. A refused COD parcel is usually different: you fulfilled the order, the courier tried to deliver it, and it came back. Shopify's help doesn't say whether the trigger also runs when you cancel an order like that.

If the run appears for your fulfilled test order, the workflow covers refused parcels on your store. If it doesn't, the workflow will only catch COD orders cancelled before they ship, which are often not refusals at all. In that case, tag refusers in batches instead: mark the returned orders with an order tag, then tag their customers together. The method is in how to tag many Shopify customers at once.

What can't the workflow know?

Flow sees that an order was cancelled and that it was a COD order. It can't see why.

  • Refused or failed? A parcel that came back because the courier had a wrong phone number looks the same as a real refusal. See fake, refused, failed: three COD problems that need different fixes.
  • Your own cancellations. An order you cancelled because an item was out of stock, or because of a staff mistake, would still match.
  • Guests. Flow can only tag a customer record that is linked to the order. Even then, a COD rule only sees the tag when the shopper is identified at checkout, for example signed in. See how to block COD for specific customers with tags.
  • One person, many records. A customer who orders with a new email address or phone number is a new customer record, without the tag.

How do you make the tagging fairer?

Use the cancellation reason. Shopify saves a reason with each cancelled order. In the API it is one of six values: CUSTOMER, DECLINED, FRAUD, INVENTORY, OTHER or STAFF. Add a second condition step, before the action, so the workflow skips orders cancelled for INVENTORY (you couldn't ship) and STAFF (your mistake). Then choose the reason carefully every time you cancel a refused order.

Tag for review first. Instead of cod-refused, let Flow add a holding tag such as cod-review. Once a week, someone looks at every customer with that tag and swaps it for cod-refused when the pattern is real. Customers with only the holding tag keep COD, because your COD rule doesn't read it.

Look at the tags every week at first. Shopify warns that another app or a staff member can overwrite customer tags, and because Flow often finishes first, its tag can disappear. Open a few recently tagged customers and check the tag is still there.

Keep a way back. A customer who pays online a few times without problems may deserve COD again. Decide when you remove the tag, and write it in your COD policy.

Is Flow the only way to find refusers?

No. You can also review cancelled COD orders by hand (how to spot repeat refusers in your Shopify orders). Khaleeji COD's refuser scan lists the customers behind cancelled COD orders from the last 60 days and tags nobody until you confirm, which suits stores that want a person to decide each case.

Sources

  1. Shopify Help Center: Shopify Flow
  2. Shopify Help Center: Flow trigger, Order canceled
  3. Shopify Help Center: Flow action, Add customer tags
  4. Shopify Help Center: Conditions in Shopify Flow
  5. Shopify Help Center: Create a new workflow
  6. Shopify Help Center: Testing workflows
  7. Shopify.dev: OrderCancelReason (GraphQL Admin API)

Checked on the date above. Shopify and courier settings change, so check the source if something looks different.

Stop paying shipping twice for refused orders

Khaleeji COD has been submitted to the Shopify App Store and is in review. Email us and we'll tell you the day it's live.

In review for the Shopify App Store · Email: