Mechanic is a development and ecommerce automation platform for Shopify. :)
This task generates a CSV spreadsheet, listing orders that are unpaid, partially paid, or pending payment. The resulting report is emailed to the recipient of your choice. Optionally, choose to have this report generated hourly, or daily.
Runs Occurs when a user manually triggers the task. Configuration includes include closed orders, recipient email address, email subject, email body, csv attachment filename, run hourly, and run daily.
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 options.run_hourly__boolean %} mechanic/scheduler/hourly {% elsif options.run_daily__boolean %} mechanic/scheduler/daily {% endif %}
{% assign orders = shop.orders %} {% if options.include_closed_orders__boolean %} {% assign orders = orders.any %} {% endif %} {% assign orders_to_report = orders.unpaid | concat: orders.partially_paid | concat: orders.pending %} {% if orders_to_report == empty and event.preview != true %} {% log "Zero orders found - skipping email. :)" %} {% else %} {% assign rows = array %} {% assign header = array %} {% assign header[0] = "Order number" %} {% assign header[1] = "Date" %} {% assign header[2] = "Customer name" %} {% assign header[3] = "Order total" %} {% assign rows[0] = header %} {% for order in orders_to_report %} {% assign row = array %} {% assign row[0] = order.name %} {% assign row[1] = order.processed_at | date: "%F" %} {% assign row[2] = order.customer.first_name | append: " " | append: order.customer.last_name | strip %} {% assign row[3] = order.total_price | money_with_currency %} {% assign rows[rows.size] = row %} {% endfor %} {% action "email" %} { "to": {{ options.recipient_email_address__email_required | json }}, "subject": {{ options.email_subject__required | json }}, "body": {{ options.email_body__required_multiline | strip | newline_to_br | json }}, "reply_to": {{ shop.customer_email | json }}, "from_display_name": {{ shop.name | json }}, "attachments": { {{ options.csv_attachment_filename__required | replace: ".csv", "" | append: ".csv" | json }}: {{ rows | csv | json }} } } {% endaction %} {% endif %}
true
Orders that require payment: {{ "now" | date: "%F" }}
Hello, Please find the attached report. Thanks! -Mechanic, for {{ shop.name }}
orders-that-require-payment-{{ "now" | date: "%Y%m%d" }}.csv