Mechanic is a development and ecommerce automation platform for Shopify. :)
Use this task to automatically categorize orders based on the cart attributes configured before checkout. Useful if you allow customers to supply extra information about their order, or if your cart has some hidden coding that adds cart attributes programatically.
Runs Occurs whenever an order is created. Configuration includes cart attribute to monitor and cart attribute values and order tags to add.
Use this task to automatically categorize orders based on the cart attributes configured before checkout. Useful if you allow customers to supply extra information about their order, or if your cart has some hidden coding that adds cart attributes programatically.
Configure the "Cart attribute to monitor" option with the exact name of the cart attribute in use. This value is case-sensitive, and must include any punctuation used in the actual cart attribute.
Configure the "Cart attribute values and order tags to add" option with an attribute value on the left, and a tag on the right, to be applied when the left-hand value is found on an order. Add as many value/tag pairs as you like. :)
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
{% comment %} Preferred order of options: {{ options.cart_attribute_to_monitor__required }} {{ options.cart_attribute_values_and_order_tags_to_add__keyval_required }} {% endcomment %} {% if event.preview %} {% capture order_json %} { "admin_graphql_api_id": "gid://shopify/Order/12345", "tags": "", "note_attributes": { {{ options.cart_attribute_to_monitor__required | json }}: {{ options.cart_attribute_values_and_order_tags_to_add__keyval_required.first.first | json }} } } {% endcapture %} {% assign order = order_json | parse_json %} {% endif %} {% assign attribute_name = options.cart_attribute_to_monitor__required %} {% assign attribute_value = order.note_attributes[attribute_name] %} {% assign tag = options.cart_attribute_values_and_order_tags_to_add__keyval_required[attribute_value] %} {% assign order_tags = order.tags | split: ", " %} {% if tag == blank %} {% log "Order does not qualify for a tag" %} {% elsif order_tags contains tag %} {% log message: "Order is already tagged", tag: tag %} {% else %} {% action "shopify" %} mutation { tagsAdd( id: {{ order.admin_graphql_api_id | json }} tags: {{ tag | json }} ) { userErrors { field message } } } {% endaction %} {% endif %}