Auto-tag new orders that have tips
This task watches for newly-paid orders, and tags any that include a customer tip, using the tag of your choice. :)
Try this taskWhen it runs
Occurs whenever an order is paid
What you choose
Tag for orders that have a tip
Task code and subscriptions
You can edit the Liquid code after installing this task. View on GitHub or ask a question in the Mechanic Slack community.
Subscriptions
shopify/orders/paid
How task subscriptions work
Option types and flags
- Tag for orders that have a tip (required)
Task code
{% if event.preview %}
{% capture order_json %}
{
"admin_graphql_api_id": "gid://shopify/Order/12345",
"tags": "",
"line_items": [
{
"id": 2345678901,
"requires_shipping": false,
"fulfillment_status": null,
"tip": {
"payment_method": "shopify_payments",
"payment_gateway": "shopify_payments"
}
}
]
}
{% endcapture %}
{% assign order = order_json | parse_json %}
{% endif %}
{% assign tip_line_items = order.line_items | where: "tip" %}
{% if tip_line_items != empty %}
{% action "shopify" %}
mutation {
tagsAdd(
id: {{ order.admin_graphql_api_id | json }}
tags: {{ options.tag_for_orders_that_have_a_tip__required | json }}
) {
userErrors {
field
message
}
}
}
{% endaction %}
{% endif %}
Mechanic Liquid reference