Mechanic is a development and ecommerce automation platform for Shopify. :)
Use this task with services that add tracking numbers to fulfillments after fulfillments are created, to ensure that customers are notified when their tracking number is available.
Runs Occurs whenever a fulfillment is created and Occurs whenever a fulfillment is updated. Configuration includes email subject and email body.
Use this task with services that add tracking numbers to fulfillments after fulfillments are created, to ensure that customers are notified when their tracking number is available.
This task works by monitoring created and updated fulfillments. It scans for and saves the tracking numbers currently available for an order, and whenever that set changes, it sends an email to the customer.
Use "TRACKING_NUMBERS" in your email body to insert a list of tracking numbers for the customer's order. Or, use "{{ fulfillment.tracking_number }}", to insert the single tracking number of the fulfillment that has just been created or updated.
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/fulfillments/create shopify/fulfillments/update
{% assign existing_metafield = fulfillment.order.metafields.mechanic | where: "key", "known_tracking_numbers" | first %} {% if event.preview %} {% capture fulfillment_json %} { "order": { "email": "customer@example.com", "metafields": { "mechanic": { "known_tracking_numbers": [] } }, "fulfillments": [ { "tracking_numbers": ["ABC123"] } ] } } {% endcapture %} {% assign fulfillment = fulfillment_json | parse_json %} {% assign existing_metafield = hash %} {% assign existing_metafield["id"] = 1234567890 %} {% endif %} {% assign already_known_tracking_numbers = fulfillment.order.metafields.mechanic.known_tracking_numbers | default: array %} {% assign currently_known_tracking_numbers = array %} {% for some_fulfillment in fulfillment.order.fulfillments %} {% assign currently_known_tracking_numbers = currently_known_tracking_numbers | concat: some_fulfillment.tracking_numbers %} {% endfor %} {% assign tracking_numbers_changed = false %} {% for tracking_number in currently_known_tracking_numbers %} {% unless already_known_tracking_numbers contains tracking_number %} {% assign tracking_numbers_changed = true %} {% break %} {% endunless %} {% endfor %} {% if tracking_numbers_changed or existing_metafield == nil %} {% if existing_metafield %} {% if fulfillment.order.email == blank %} {% log "No email on file for this order." %} {% else %} {% assign tracking_numbers_string = currently_known_tracking_numbers | join: ", " %} {% action "email" %} { "to": {{ fulfillment.order.email | json }}, "subject": {{ options.email_subject__required | json }}, "body": {{ options.email_body__required_multiline | replace: "TRACKING_NUMBERS", tracking_numbers_string | strip | newline_to_br | json }}, "reply_to": {{ shop.customer_email | json }}, "from_display_name": {{ shop.name | json }} } {% endaction %} {% endif %} {% endif %} {% action "shopify" %} [ "update", [ "order", {{ fulfillment.order.id | json }} ], { "metafields": [ { {% if existing_metafield %}"id": {{ existing_metafield.id | json }},{% endif %} "namespace": "mechanic", "key": "known_tracking_numbers", "value": {{ currently_known_tracking_numbers | json | json }}, "type": "json" } ] } ] {% endaction %} {% endif %}
Shipping update for order {{ fulfillment.order.name | default: "(number)" }}
Hello customer, Track your package: TRACKING_NUMBERS Thanks, {{ shop.name }}