Mechanic is a development and ecommerce automation platform for Shopify. :)
This task runs when an order is updated. When the tag of your choice is found in the order's tag list, all of its fulfillments (if any) will be cancelled, and the aforementioned tag will be removed.
Runs Occurs whenever an order is updated. Configuration includes required order tag.
This task runs when an order is updated. When the tag of your choice is found in the order's tag list, all of its fulfillments (if any) will be cancelled, and the aforementioned tag will be removed.
Notes:
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/updated
{% capture query %} query { order(id: {{ order.admin_graphql_api_id | json }}) { id tags fulfillments { id status } } } {% endcapture %} {% assign result = query | shopify %} {% if event.preview %} {% capture result_json %} { "data": { "order": { "id": "gid://shopify/Order/1234567890", "tags": {{ options.required_order_tag__required | json }}, "fulfillments": [ { "id": "gid://shopify/Fulfillment/1234567890", "status": "SUCCESS" } ] } } } {% endcapture %} {% assign result = result_json | parse_json %} {% endif %} {% assign order = result.data.order %} {% if order.tags contains options.required_order_tag__required %} {% for fulfillment in order.fulfillments %} {% if fulfillment.status == "CANCELLED" %} {% continue %} {% endif %} {% action "shopify" %} mutation { fulfillmentCancel(id: {{ fulfillment.id | json }}) { fulfillment { id status } userErrors { field message } } } {% endaction %} {% endfor %} {% action "shopify" %} mutation { tagsRemove( id: {{ order.id | json }} tags: {{ options.required_order_tag__required | json }} ) { userErrors { field message } } } {% endaction %} {% endif %}