Mechanic is a development and ecommerce automation platform for Shopify. :)
Use this task to automatically remove a certain customer tag whenever a particular product is refunded, for that customer.
Runs Occurs whenever a new refund is created without errors on an order, independent from the movement of money. Configuration includes product ids and customer tag to remove.
Use this task to automatically remove a certain customer tag whenever a particular product is refunded, for that customer.
This task is configured with one or more product IDs (learn how to find a product ID), and with the customer tag to remove when one of those products is refunded.
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/refunds/create
{% if event.preview %} {% assign refund = hash %} {% assign refund["refund_line_items"] = array %} {% assign refund["refund_line_items"][0] = hash %} {% assign refund["refund_line_items"][0]["line_item"] = hash %} {% assign refund["refund_line_items"][0]["line_item"]["product_id"] = options.product_ids__number_array_required.first %} {% assign refund["order"] = hash %} {% assign refund["order"]["customer"] = hash %} {% assign refund["order"]["customer"]["admin_graphql_api_id"] = "gid://shopify/Customer/1234567890" %} {% assign refund["order"]["customer"]["tags"] = options.customer_tag_to_remove__required %} {% endif %} {% assign refunded_product_ids = refund.refund_line_items | map: "line_item" | map: "product_id" %} {% assign refund_qualifies = false %} {% for product_id in options.product_ids__number_array_required %} {% if refunded_product_ids contains product_id %} {% assign refund_qualifies = true %} {% break %} {% endif %} {% endfor %} {% assign customer = refund.order.customer %} {% assign customer_tags = refund.order.customer.tags | split: "," %} {% if refund_qualifies and customer_tags contains options.customer_tag_to_remove__required %} {% action "shopify" %} mutation { tagsRemove( id: {{ customer.admin_graphql_api_id | json }} tags: {{ options.customer_tag_to_remove__required | json }} ) { userErrors { field message } } } {% endaction %} {% endif %}