-
Notifications
You must be signed in to change notification settings - Fork 35
/
remove-a-customer-tag-when-another-tag-is-added.json
23 lines (23 loc) · 1.78 KB
/
remove-a-customer-tag-when-another-tag-is-added.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
"docs": "Does exactly as it says. :)",
"halt_action_run_sequence_on_error": false,
"name": "Remove a customer tag when another tag is added",
"online_store_javascript": null,
"options": {
"customer_tag_to_watch_for__required": null,
"customer_tag_to_remove__required": null,
"ignore_tag_case__boolean": true
},
"order_status_javascript": null,
"perform_action_runs_in_sequence": false,
"script": "{% if event.preview %}\n {% assign customer = hash %}\n {% assign customer[\"admin_graphql_api_id\"] = \"gid://shopify/Customer/1234567890\" %}\n {% assign customer[\"tags\"] = options.customer_tag_to_watch_for__required | append: \", \" | append: options.customer_tag_to_remove__required %}\n{% endif %}\n\n{% assign customer_tags = customer.tags | split: \", \" %}\n{% assign tag_to_match = options.customer_tag_to_watch_for__required %}\n{% assign tag_to_remove = options.customer_tag_to_remove__required %}\n\n{% if options.ignore_tag_case__boolean %}\n {% assign customer_tags = customer.tags | downcase | split: \", \" %}\n {% assign tag_to_match = options.customer_tag_to_watch_for__required | downcase %}\n {% assign tag_to_remove = options.customer_tag_to_remove__required | downcase %}\n{% endif %}\n\n{% if customer_tags contains tag_to_match and customer_tags contains tag_to_remove %}\n {% action \"shopify\" %}\n mutation {\n tagsRemove(\n id: {{ customer.admin_graphql_api_id | json }}\n tags: {{ options.customer_tag_to_remove__required | json }}\n ) {\n userErrors {\n field\n message\n }\n }\n }\n {% endaction %}\n{% endif %}",
"subscriptions": [
"shopify/customers/update"
],
"subscriptions_template": "shopify/customers/update",
"tags": [
"Customers",
"Untag",
"Watch"
]
}