Remove an order tag when another tag is added
Does exactly as it says. :)
Try this taskWhen it runs
Occurs whenever an order is updated
What you choose
- Order tag to watch for
- Order tag to remove
- Ignore tag case
Task code and subscriptions
You can edit the Liquid code after installing this task. View on GitHub or ask a question in the Mechanic Slack community.
Subscriptions
shopify/orders/updated
How task subscriptions work
Option types and flags
- Order tag to watch for (required)
- Order tag to remove (required)
- Ignore tag case (boolean)
Task code
{% if event.preview %}
{% assign order = hash %}
{% assign order["admin_graphql_api_id"] = "gid://shopify/Order/1234567890" %}
{% assign order["tags"] = options.order_tag_to_watch_for__required | append: ", " | append: options.order_tag_to_remove__required %}
{% endif %}
{% assign order_tags = order.tags | split: ", " %}
{% assign tag_to_match = options.order_tag_to_watch_for__required %}
{% assign tag_to_remove = options.order_tag_to_remove__required %}
{% if options.ignore_tag_case__boolean %}
{% assign order_tags = order.tags | downcase | split: ", " %}
{% assign tag_to_match = options.order_tag_to_watch_for__required | downcase %}
{% assign tag_to_remove = options.order_tag_to_remove__required | downcase %}
{% endif %}
{% if order_tags contains tag_to_match and order_tags contains tag_to_remove %}
{% action "shopify" %}
mutation {
tagsRemove(
id: {{ order.admin_graphql_api_id | json }}
tags: {{ options.order_tag_to_remove__required | json }}
) {
userErrors {
field
message
}
}
}
{% endaction %}
{% endif %}
Mechanic Liquid reference
Default option values
- Order tag to watch for
apple- Order tag to remove
butter- Ignore tag case
true