Remove a customer tag when another tag is added
Does exactly as it says. :)
Try this taskWhen it runs
Occurs whenever a customer is updated
What you choose
- Customer tag to watch for
- Customer 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/customers/update
How task subscriptions work
Option types and flags
- Customer tag to watch for (required)
- Customer tag to remove (required)
- Ignore tag case (boolean)
Task code
{% if event.preview %}
{% assign customer = hash %}
{% assign customer["admin_graphql_api_id"] = "gid://shopify/Customer/1234567890" %}
{% assign customer["tags"] = options.customer_tag_to_watch_for__required | append: ", " | append: options.customer_tag_to_remove__required %}
{% endif %}
{% assign customer_tags = customer.tags | split: ", " %}
{% assign tag_to_match = options.customer_tag_to_watch_for__required %}
{% assign tag_to_remove = options.customer_tag_to_remove__required %}
{% if options.ignore_tag_case__boolean %}
{% assign customer_tags = customer.tags | downcase | split: ", " %}
{% assign tag_to_match = options.customer_tag_to_watch_for__required | downcase %}
{% assign tag_to_remove = options.customer_tag_to_remove__required | downcase %}
{% endif %}
{% if customer_tags contains tag_to_match and customer_tags contains tag_to_remove %}
{% action "shopify" %}
mutation {
tagsRemove(
id: {{ customer.admin_graphql_api_id | json }}
tags: {{ options.customer_tag_to_remove__required | json }}
) {
userErrors {
field
message
}
}
}
{% endaction %}
{% endif %}
Mechanic Liquid reference
Default option values
- Ignore tag case
true