Mechanic is a development and ecommerce automation platform for Shopify. :)
This task demonstrates Mechanic's ability to compile a CSV export, and send it as an email attachment. In this example, we bundle up a simple export of product titles and IDs, and email it as a CSV attachment.
Runs Occurs when a user manually triggers the task. Configuration includes email recipient.
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?)
mechanic/user/trigger
{% if event.preview %} {% capture shop_json %} { "products": [ { "id": 1234567890, "title": "Short sleeve t-shirt" } ] } {% endcapture %} {% assign shop = shop_json | parse_json %} {% endif %} {% assign rows = array %} {% assign header = array %} {% assign header[0] = "Product ID" %} {% assign header[1] = "Product Title" %} {% assign rows[0] = header %} {% for product in shop.products %} {% assign row = array %} {% assign row[0] = product.id %} {% assign row[1] = product.title %} {% assign rows[rows.size] = row %} {% endfor %} {% assign csv = rows | csv %} {% action "email" %} { "to": {{ options.email_recipient__email_required | json }}, "subject": {{ "Product ID export for " | append: shop.name | json }}, "body": "Please see attached. :)", "reply_to": {{ shop.customer_email | json }}, "from_display_name": {{ shop.name | json }}, "attachments": { "export.csv": {{ csv | json }} } } {% endaction %} {% action "echo" csv %}