Download and email a file to a customer, when purchased, with Mechanic.

Mechanic is a development and ecommerce automation platform for Shopify. :)

Download and email a file to a customer, when purchased

This task watches for newly-paid orders. When an order contains a certain line item, this task retrieves a file from the URL of your choice, and emails that file to the customer. Because URLs are easier to share, this makes for a safer way to distribute downloadable materials.

Runs Occurs whenever an order is paid. Configuration includes required line item title, email subject, email body, attachment filename, and attachment url.

15-day free trial – unlimited tasks

Documentation

This task watches for newly-paid orders. When an order contains a certain line item, this task retrieves a file from the URL of your choice, and emails that file to the customer. Because URLs are easier to share, this makes for a safer way to distribute downloadable materials.

Shopify allows file uploads via the "Files" page. Once uploaded, you'll receive a URL which can be used for this task. Learn how to upload files to Shopify.

Developer details

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?)

Open source
View on GitHub to contribute to this task
Subscriptions
shopify/orders/paid
Tasks use subscriptions to sign up for specific kinds of events. Learn more
Options
required line item title (required), email subject (required), email body (required, multiline), attachment filename (required), attachment url (required)
Code
{% if event.preview %}
  {% capture order_json %}
    {
      "line_items": [
        {
          "title": {{ options.required_line_item_title__required | json }}
        }
      ]
    }
  {% endcapture %}

  {% assign order = order_json | parse_json %}
{% endif %}

{% assign line_item_titles = order.line_items | map: "title" %}

{% if line_item_titles contains options.required_line_item_title__required %}
  {% action "email" %}
    {
      "to": {{ order.email | json }},
      "subject": {{ options.email_subject__required | json }},
      "body": {{ options.email_body__required_multiline | newline_to_br | json }},
      "reply_to": {{ shop.customer_email | json }},
      "from_display_name": {{ shop.name | json }},
      "attachments": {
        {{ options.attachment_filename__required | json }}: {
          "url": {{ options.attachment_url__required | json }}
        }
      }
    }
  {% endaction %}
{% endif %}
Task code is written in Mechanic Liquid, an extension of open-source Liquid enhanced for automation. Learn more
Defaults
Required line item title
Course
Email subject
Here's your purchased course! (Order {{ order.name }})
Email body
Hey there! Thanks for purchasing this course. You'll find the PDF attached to this email. :)

Thanks,
{{ shop.name }}
Attachment filename
Course for order {{ order.name }}.pdf
Attachment URL
https://example.com/course.pdf