Mechanic is a development and ecommerce automation platform for Shopify. :)
This task checks for incoming orders, watching for orders that have a specific cart attribute filled in. When present, the task then copies that attribute over to the order's tags.
Runs Occurs whenever an order is created. Configuration includes cart attribute to monitor.
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 %} {% capture order_json %} { "admin_graphql_api_id": "gid://shopify/Order/12345", "tags": "", "note_attributes": { {{ options.cart_attribute_to_monitor__required | json }}: "Hello!" } } {% endcapture %} {% assign order = order_json | parse_json %} {% endif %} {% assign order_tags = order.tags | split: ", " %} {% assign attribute_name = options.cart_attribute_to_monitor__required %} {% assign attribute_value = order.note_attributes[attribute_name] %} {% if attribute_value == blank %} {% log "Attribute is not present" %} {% elsif order_tags contains attribute_value %} {% log message: "Order is already tagged", tag: attribute_value %} {% else %} {% action "shopify" %} mutation { tagsAdd( id: {{ order.admin_graphql_api_id | json }} tags: {{ attribute_value | json }} ) { userErrors { field message } } } {% endaction %} {% endif %}