Mechanic is a development and ecommerce automation platform for Shopify. :)
This task monitors newly-created orders, and appends an order note if that order was created with a certain tag.
Runs Occurs whenever an order is created. Configuration includes required order tag and order note to add.
This task monitors newly-created orders, and appends an order note if that order was created with a certain tag.
Note: this task does not monitor order updates, and so tags added later will not add an order note.
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
{% assign required_tag_downcased = options.required_order_tag__required | downcase %}
{% if event.preview %}
{% capture order_json %}
{
"note": "An existing order note",
"name": "#9999",
"admin_graphql_api_id": "gid:\/\/shopify\/Order\/1234567890",
"tags": {{ options.required_order_tag__required | json }}
}
{% endcapture %}
{% assign order = order_json | parse_json %}
{% endif %}
{% assign tags_downcased = order.tags | downcase | split: ", " %}
{% if tags_downcased contains required_tag_downcased %}
{% assign note = order.note | append: newline | append: newline | append: options.order_note_to_add__required_multiline | strip %}
{% action "shopify" %}
mutation {
orderUpdate(
input: {
id: {{ order.admin_graphql_api_id | json }}
note: {{ note | json }}
}
) {
userErrors {
field
message
}
}
}
{% endaction %}
{% else %}
{% log order_tags: order.tags %}
{% endif %}foo
bar