Mechanic is a development and ecommerce automation platform for Shopify. :)
Does exactly as it says. :)
Runs Occurs whenever an order is updated. Configuration includes tags to watch for and tags to add and remove tag to add when the corresponding tag to watch for is removed.
Does exactly as it says. :)
Configure this task with order tags to watch for on the left, and associated tags to add on the right. (Feel free to use a comma-delimited list on the right side, too.) This task will run whenever an order is created or updated, tagging as configured.
Mechanic is designed to benefit everybody: merchants, customers, developers, agencies, Shopifolks, everybody.
That’s why we make it easy to configure automation without code, why we make it easy to tweak the underlying code once tasks are installed, and why we publish it all here for everyone to learn from.
(By the way, have you seen our documentation? Have you joined the Slack community?)
shopify/orders/updated
{% if event.preview %} {% assign order = hash %} {% assign order["admin_graphql_api_id"] = "gid://shopify/Order/1234567890" %} {% assign order["tags"] = options.tags_to_watch_for_and_tags_to_add__keyval_required.first.first %} {% endif %} {% assign existing_tags = order.tags | split: ", " %} {% assign deserved_tags = array %} {% assign tags_to_add = array %} {% assign tags_to_remove = array %} {% for keyval in options.tags_to_watch_for_and_tags_to_add__keyval_required %} {% assign tag_to_watch_for = keyval[0] %} {% unless existing_tags contains tag_to_watch_for %} {% continue %} {% endunless %} {% assign tags = keyval[1] | replace: ", ", "," | split: "," %} {% assign deserved_tags = deserved_tags | concat: tags %} {% for tag in tags %} {% unless existing_tags contains tag %} {% assign tags_to_add[tags_to_add.size] = tag %} {% endunless %} {% endfor %} {% endfor %} {% if options.remove_tag_to_add_when_the_corresponding_tag_to_watch_for_is_removed__boolean %} {% for keyval in options.tags_to_watch_for_and_tags_to_add__keyval_required %} {% assign tag_to_watch_for = keyval[0] %} {% if existing_tags contains tag_to_watch_for %} {% continue %} {% endif %} {% assign tags = keyval[1] | replace: ", ", "," | split: "," %} {% for tag in tags %} {% unless existing_tags contains tag %} {% continue %} {% endunless %} {% if deserved_tags contains tag %} {% continue %} {% endif %} {% assign tags_to_remove[tags_to_remove.size] = tag %} {% endfor %} {% endfor %} {% endif %} {% if tags_to_add != empty or tags_to_remove != empty %} {% action "shopify" %} mutation { {% if tags_to_add != empty %} tagsAdd( id: {{ order.admin_graphql_api_id | json }} tags: {{ tags_to_add | json }} ) { userErrors { field message } } {% endif %} {% if tags_to_remove != empty %} tagsRemove( id: {{ order.admin_graphql_api_id | json }} tags: {{ tags_to_remove | json }} ) { userErrors { field message } } {% endif %} } {% endaction %} {% endif %}