Auto-tag new orders based on payment method
This task checks the payment method for new orders immediately upon order creation, and tags the order accordingly.
Try this taskWhen it runs
Occurs whenever an order is created
What you choose
- Payment gateway name
- Order tag to add
Documentation
This task checks the payment method for new orders immediately upon order creation, and tags the order accordingly.
Tip: to tag orders paid with a gift card, fill in "Payment gateway name" with "gift_card".
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/create
How task subscriptions work
Option types and flags
- Payment gateway name (required)
- Order tag to add (required)
Task code
{% if event.preview %}
{% capture order_json %}
{
"admin_graphql_api_id": "gid://shopify/Order/12345",
"payment_gateway_names": {{ options.payment_gateway_name__required | json }}
}
{% endcapture %}
{% assign order = order_json | parse_json %}
{% endif %}
{% if order.payment_gateway_names contains options.payment_gateway_name__required %}
{% action "shopify" %}
mutation {
tagsAdd(
id: {{ order.admin_graphql_api_id | json }}
tags: {{ options.order_tag_to_add__required | json }}
) {
userErrors {
field
message
}
}
}
{% endaction %}
{% else %}
{% log order_payment_gateway_names: order.payment_gateway_names %}
{% endif %}
Mechanic Liquid reference