Remind customers every x days about unpaid orders with Mechanic.

Mechanic is an automation and development platform for Shopify. :)

Remind customers every x days about unpaid orders

by Isaac Bowen (team@usemechanic.com)

This task emails customers right away about unpaid orders, and then continues to email them every (x) days until the order is paid.

Runs when an order is created and 1 days after user/orders/unpaid_reminder is triggered. Configuration includes number of days to wait between emails, email subject, and email body.

15-day free trial – unlimited tasks

Developer details

Mechanic is designed to benefit everybody: merchants, customers, developers, agencies, Gurus, 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.

Events
when an order is created (shopify/orders/create)
1 days after user/orders/unpaid_reminder is triggered (user/orders/unpaid_reminder+1.days)
Options
number of days to wait between emails (number, required), email subject (required), email body (multiline, required)
Script
{% comment %}
  Option order:

  {{ options.number_of_days_to_wait_between_emails__number_required }}
  {{ options.email_subject__required }}
  {{ options.email_body__multiline_required }}
{% endcomment %}

{% if options.number_of_days_to_wait_between_emails__number_required < 1 %}
  {"error": "'Number of days to wait between emails' must be >= 1!"}
{% endif %}

{% if event.preview %}
  {% assign order = '{"id":1234567890,"name": "#1234"}' | parse_json %}
{% elsif event.topic == "user/orders/unpaid_reminder" %}
  {% assign order = shop.orders[event.data.order_id] %}
{% endif %}

{% assign order_qualifies = false %}
{% if order.financial_status == "pending" and order.cancelled_at == blank %}
  {% assign order_qualifies = true %}
{% endif %}

{% if event.preview or order_qualifies %}
  {% action "email" %}
    {
      "to": {{ order.email | json }},
      "reply_to": {{ shop.customer_email | json }},
      "subject": {{ options.email_subject__required | replace: "ORDER_NAME", order.name | json }},
      "body": {{ options.email_body__multiline_required | strip | newline_to_br | json }},
      "from_display_name": {{ shop.name | json }}
    }
  {% endaction %}

  {% action "event" %}
    {
      "topic": "user/orders/unpaid_reminder",
      "data": {
        "order_id": {{ order.id | json }}
      },
      "task_id": {{ task.id | json }}
    }
  {% endaction %}
{% endif %}
Mechanic tasks are written in Liquid, which makes them easy to write and easy to modify. Learn more about our platform.
Defaults
Email subject
Don't forget! Order ORDER_NAME still needs to be paid
Email body
Hi there,

Your payment is still required! Please get in touch at {{ shop.customer_email }} to proceed.

Thanks,
{{ shop.name }}