Mechanic is a development and ecommerce automation platform for Shopify. :)
Use this task to get an email alert with a list of the returned items whenever a return is marked as closed.
Runs Occurs whenever a return is closed. Configuration includes email recipients.
Use this task to get an email alert with a list of the returned items whenever a return is marked as closed.
Note: this event will not occur when returns or exchanges are made via a POS terminal.
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/returns/close
{% assign email_recipients = options.email_recipients__array_required %} {% if event.topic == "shopify/returns/close" %} {% capture query %} query { return(id: {{ return.admin_graphql_api_id | json }}) { name returnLineItems(first: 100) { nodes { ... on ReturnLineItem { quantity returnReason fulfillmentLineItem { lineItem { name sku } } } } } } } {% endcapture %} {% assign result = query | shopify %} {% if event.preview %} {% capture result_json %} { "data": { "return": { "name": "#PREVIEW-R1", "returnLineItems": { "nodes": [ { "quantity": 1, "returnReason": "STYLE", "fulfillmentLineItem": { "lineItem": { "name": "Widget - Chartreuse", "sku": "WDGT-CHRTRS" } } } ] } } } } {% endcapture %} {% assign result = result_json | parse_json %} {% endif %} {% assign return_line_items = result.data.return.returnLineItems.nodes %} {% if return_line_items == blank %} {% log message: "No verified return line items were found on this return.", return: result.data.return %} {% break %} {% endif %} {% capture email_subject %}ALERT: New return {{ result.data.return.name }}{% endcapture %} {% capture email_body -%} Returned items ============== {% for return_line_item in return_line_items %} Title: <strong>{{ return_line_item.fulfillmentLineItem.lineItem.name }}</strong> SKU: <strong>{{ return_line_item.fulfillmentLineItem.lineItem.sku }}</strong> Quantity: <strong>{{ return_line_item.quantity }}</strong> Reason: <strong>{{ return_line_item.returnReason }}</strong> {% endfor %} {% endcapture %} {% action "email" %} { "to": {{ email_recipients | json }}, "subject": {{ email_subject | json }}, "body": {{ email_body | newline_to_br | json }}, "reply_to": {{ shop.customer_email | json }}, "from_display_name": {{ shop.name | json }} } {% endaction %} {% endif %}