Mechanic is a development and ecommerce automation platform for Shopify. :)
Use this task to apply certain tags to newly-created orders, based on what tags are on the associated customer. Configure this task with one-to-one mappings of customer tags to look for, connected to order tags to add.
Runs Occurs whenever an order is created. Configuration includes customer tags to look for and order tags to add.
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/create
{% if event.preview %} {% assign order = hash %} {% assign order["admin_graphql_api_id"] = "gid://shopify/Order/123456780" %} {% assign order["customer"] = hash %} {% assign order["customer"]["tags"] = options.customer_tags_to_look_for_and_order_tags_to_add__keyval.first.first %} {% endif %} {% assign customer_tags = order.customer.tags | split: ", " %} {% assign tags_to_add = array %} {% assign tag_pairs = options.customer_tags_to_look_for_and_order_tags_to_add__keyval %} {% for pair in tag_pairs %} {% if customer_tags contains pair.first %} {% assign tags_to_add = tags_to_add | add_tag: pair.last %} {% endif %} {% endfor %} {% if tags_to_add != empty %} {% action "shopify" %} mutation { tagsAdd( id: {{ order.admin_graphql_api_id | json }} tags: {{ tags_to_add | json }} ) { userErrors { field message } } } {% endaction %} {% endif %}
{"wholesale-customer"=>"wholesale-order"}