Mechanic is a development and ecommerce automation platform for Shopify. :)
Use this task to immediately bump orders, from certain customers, to "paid". Useful if you have a standing payment arrangement for certain customers. Optionally, auto-remove this tag from customers after auto-paying their order. Useful for using customer tags as one-time triggers for auto-payment.
Runs Occurs whenever an order is created and Occurs when a user manually triggers the task. Configuration includes required customer tag and remove tag from customer after processing their order.
Use this task to immediately bump orders, from certain customers, to "paid". Useful if you have a standing payment arrangement for certain customers. Optionally, auto-remove this tag from customers after auto-paying their order. Useful for using customer tags as one-time triggers for auto-payment.
This task runs automatically for incoming orders. Run this task manually to scan your store's order history, processing orders that were previously placed. (To scan orders older than 60 days, enable "Read all orders".)
Enable the "Remove tag from customer after processing their order" option to have this task remove the required tag whenever this task marks an order of theirs as paid. (If run manually, this task will still mark all of the qualifying customer's orders as paid, not just one order.)
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 mechanic/user/trigger
{% assign tag_to_match = options.required_customer_tag__required | downcase %} {% if event.topic contains "shopify/orders" %} {% assign customer_tags = order.customer.tags | downcase | split: ", " %} {% capture order_query %} query { order(id: {{ order.admin_graphql_api_id | json }}) { canMarkAsPaid } } {% endcapture %} {% assign order_result = order_query | shopify %} {% if event.preview or customer_tags contains tag_to_match %} {% if order_result.data.order.canMarkAsPaid == false %} {"log": "Order cannot be manually marked as paid - skipping."} {% else %} {% action "shopify" %} mutation { orderMarkAsPaid(input: { id: {{ order.admin_graphql_api_id | json }} }) { order { fullyPaid } userErrors { field message } } {% if options.remove_tag_from_customer_after_processing_their_order__boolean %} tagsRemove( id: {% if event.preview %}"gid://shopify/Customer/1234567890"{% else %}{{ order.customer.admin_graphql_api_id | json }}{% endif %} tags: {{ options.required_customer_tag__required | json }} ) { userErrors { field message } } {% endif %} } {% endaction %} {% endif %} {% endif %} {% elsif event.topic == "mechanic/user/trigger" %} {% assign cursor = nil %} {% for n in (0..100) %} {% capture orders_query %} query { orders( first: 250 after: {{ cursor | json }} query: "-financial_status:paid" ) { pageInfo { hasNextPage } edges { cursor node { id canMarkAsPaid customer { id tags } } } } } {% endcapture %} {% assign orders_result = orders_query | shopify %} {% for edge in orders_result.data.orders.edges %} {% assign order_node = edge.node %} {% if order_node.canMarkAsPaid %} {% assign customer_tags = order_node.customer.tags | join: ", " | downcase | split: ", " %} {% if customer_tags contains tag_to_match %} {% action "shopify" %} mutation { orderMarkAsPaid(input: { id: {{ order_node.id | json }} }) { order { fullyPaid } userErrors { field message } } {% if options.remove_tag_from_customer_after_processing_their_order__boolean %} tagsRemove( id: {% if event.preview %}"gid://shopify/Customer/1234567890"{% else %}{{ order_node.customer.id | json }}{% endif %} tags: {{ options.required_customer_tag__required | json }} ) { userErrors { field message } } {% endif %} } {% endaction %} {% endif %} {% endif %} {% endfor %} {% if orders_result.data.orders.pageInfo.hasNextPage %} {% assign cursor = orders_result.data.orders.edges.last.cursor %} {% else %} {% break %} {% endif %} {% endfor %} {% endif %}
autopay