Shopify Flow's Tag Removal Bug: Handling Emojis & Single Quotes with a Liquid Fix
Hey everyone! Your friendly Shopify expert here, diving into a really interesting, albeit a bit frustrating, discussion that popped up in the community forums recently. It’s all about Shopify Flow, specifically its “Remove order tags” action, and how it sometimes throws a curveball when dealing with special characters like single quotes or, believe it or not, emojis!
If you're using Flow to automate your tag management – and honestly, who isn't trying to streamline things? – then you know how crucial it is for those automations to run smoothly. But what happens when a seemingly straightforward action starts misbehaving? That’s exactly what one savvy store owner, pepsimax2k, ran into, and their detective work, along with some community input, gives us some valuable insights.
The Gnarly Bug in Shopify Flow's Tag Removal
The core issue, as pepsimax2k initially reported, was pretty specific: when trying to remove a list of order tags that included emojis or single quotes, only the first problematic tag would actually get removed. All the subsequent emoji or single-quote containing tags would just... stay put. Regular, plain-text tags, however, were getting deleted without a hitch.
This immediately sparked some head-scratching. Was it a parsing error? A unicode issue? Maximus3 jumped in with a great diagnostic question, suggesting to test without apostrophes to help narrow down whether it was the quotes or the emojis causing the hiccup. While the thread doesn't explicitly state the outcome of that particular test, pepsimax2k's follow-up confirmed the bug persisted with both single quotes and emojis.
They even shared a snippet of what the tags array looked like when being sent to the “remove order tags” action, illustrating the problem perfectly:
{
“order_id”: “gid://shopify/Order/6892313575681”,
“tags”: [
“'
”,
“'
”,
“'
”,
“'
”,
“'
”,
“'
”,
“'
”,
“'
”,
“'
”,
“potato”
]
}
See how each emoji tag starts with a single quote? This structure, combined with the emojis, seems to be the culprit. It definitely points to a parsing quirk within Flow, where it might be struggling to correctly interpret and process multiple special character tags in a list.
Why This Matters (and a heads-up on potential 'injection')
For store owners, this is more than just a minor annoyance. If you rely on Flow to clean up or categorize orders using tags that include special characters (like marking specific orders with an emoji for quick visual scanning, or using tags with apostrophes for certain product types), this bug can throw a wrench in your automation. Your tags won't be removed as expected, leading to cluttered or miscategorized orders.
On a more technical note, pepsimax2k also brought up a valid concern about potential #injection issues if Flow isn't properly escaping tag text. While we don't have confirmation that this is the case, it’s a good reminder that robust platforms should always handle user-generated content (like tag names) with strong escaping mechanisms to prevent security vulnerabilities.
The Savvy Community Workaround: Liquid to the Rescue!
Thankfully, pepsimax2k wasn't deterred and found a clever workaround using Liquid. Instead of directly listing the problematic tags for removal, the solution involves dynamically building a comma-separated string of tags to remove based on whether they contain specific characters or emojis.
Here's the Liquid code they shared:
{% for tag in order.tags %}{% if tag contains “
” or tag contains “
” or tag contains “
” or tag contains “
” or tag contains “
” or tag contains “
” or tag contains “
” or tag contains “
” or tag contains “
” or tag contains “
” %}{{ tag }},{% endif %}{% endfor %}
What this Liquid snippet does is pretty clever: it loops through all the tags currently on an order (order.tags). For each tag, it checks if it contains any of the specified emoji characters. If it does, it outputs that tag followed by a comma. The result is a single, comma-separated string of only the tags you want to remove, which you then feed into the “Remove order tags” action in Flow.
This approach effectively bypasses the parsing issue by generating a consolidated string rather than relying on Flow to parse an array of individual, problematic tag strings. It also allows for more flexible matching, using contains instead of an exact match, which can be useful if your tags might vary slightly but still include a common identifier like an emoji.
Instructions: Implementing the Liquid Workaround in Shopify Flow
If you're facing this bug, here’s how you can implement this workaround in your Shopify Flow:
- Identify Your Target Tags: First, know exactly which emojis or special characters are causing trouble in your order tags.
- Create or Edit Your Flow: In your Shopify admin, navigate to Shopify Flow. Either create a new flow or edit an existing one where you need to remove these specific tags.
- Add a "Remove order tags" Action: At the point in your flow where you want to remove the tags, add the "Remove order tags" action.
- Insert the Liquid Code: In the field where you typically list the tags to remove (e.g., "Tags to remove"), you'll insert the Liquid code. You'll need to adapt
pepsimax2k's code to specifically target the emojis or characters you're using. - Customize the Liquid (Important!):
Take the provided Liquid snippet:
{% for tag in order.tags %}{% if tag contains “
” or tag contains “
” or tag contains “
” or tag contains “
” or tag contains “
” or tag contains “
” or tag contains “
” or tag contains “
” or tag contains “
” or tag contains “
” %}{{ tag }},{% endif %}{% endfor %}Replace the
tags for the emojis and anyor tag contains "..."conditions with the actual text or characters you want to target. For example, if you wanted to remove tags containing an apostrophe, you'd addor tag contains "'"(making sure to handle escaping if needed, but in Liquidcontainsusually handles single quotes fine). If you're using specific text strings, just put those in thecontainscondition. - Test Your Flow: Always, always test your Flow after making changes, especially with Liquid. Run a test order or manually trigger the flow on an order with the problematic tags to ensure they are removed as expected.
It's pretty amazing to see the community come together to debug and find solutions for these kinds of platform quirks. While we hope Shopify will eventually iron out these parsing issues in Flow’s "Remove order tags" action, this Liquid workaround is a fantastic way to keep your automations running smoothly in the meantime. Big thanks to pepsimax2k for sharing their discovery and solution!
If you encounter similar issues or find other clever workarounds, don't hesitate to share them. That's how we all grow and make our Shopify stores even better!