Mechanic is a development and ecommerce automation platform for Shopify. :)
Shopify allows orders to have custom attributes associated with them – and these attributes can be edited from within Shopify. Use this task to configure default attributes to be added to all new orders, providing an attribute name and (optionally) a value. Feel free to leave the value blank if you know you'll want to add your own values later, within Shopify.
Runs Occurs whenever an order is created. Configuration includes default order attributes 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/1234567890" %} {% assign order["note_attributes"] = array %} {% assign order["note_attributes"][0] = hash %} {% assign order["note_attributes"][0]["name"] = "Existing attribute name" %} {% assign order["note_attributes"][0]["value"] = "Existing attribute value" %} {% endif %} {% assign attributes = array %} {% for pair in options.default_order_attributes_to_add__keyval_required %} {% assign attribute = hash %} {% assign attribute["key"] = pair[0] %} {% assign attribute["value"] = "" | append: pair[1] %} {% assign attributes[attributes.size] = attribute %} {% endfor %} {% for note_attribute in order.note_attributes %} {% assign attribute = hash %} {% assign attribute["key"] = note_attribute.name %} {% assign attribute["value"] = note_attribute.value %} {% assign attributes[attributes.size] = attribute %} {% endfor %} {% action "shopify" %} mutation { orderUpdate( input: { id: {{ order.admin_graphql_api_id | json }} customAttributes: {{ attributes | graphql_arguments }} } ) { order { customAttributes { key value } } userErrors { field message } } } {% endaction %}
{"Assigned CSM" => ""}