Remind customers every x days about unpaid orders, with Mechanic.

Mechanic is an automation development platform for Shopify. :)

Remind customers every x days about unpaid orders

by Isaac Bowen (team@usemechanic.com)

This task sends repeating/looping reminders to customers, reminding them every x days (or hours!) about unpaid orders, until the order is no longer "pending" or until the order is cancelled.

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, use hours instead of days, send the first email when the order is created, email subject, and email body.

15-day free trial – unlimited tasks

Documentation

This task sends repeating/looping reminders to customers, reminding them every x days (or hours!) about unpaid orders, until the order is no longer "pending" or until the order is cancelled.

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), use hours instead of days (boolean), send the first email when the order is created (boolean), email subject (required), email body (multiline, required)
Script
{% comment %}
  Option order:

  {{ options.number_of_days_to_wait_between_emails__number_required }}
  {{ options.use_hours_instead_of_days__boolean }}
  {{ options.send_the_first_email_when_the_order_is_created__boolean }}
  {{ 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 %}
  {% unless options.send_the_first_email_when_the_order_is_created__boolean == false and event.topic == "shopify/orders/create" %}
    {% action "email" %}
      {
        "to": {{ order.email | json }},
        "reply_to": {{ shop.customer_email | json }},
        "subject": {{ options.email_subject__required | replace: "ORDER_NAME", order.name | replace: "CUSTOMER_FIRST_NAME", order.customer.first_name | json }},
        "body": {{ options.email_body__multiline_required | replace: "ORDER_NAME", order.name | replace: "CUSTOMER_FIRST_NAME", order.customer.first_name | strip | newline_to_br | json }},
        "from_display_name": {{ shop.name | json }}
      }
    {% endaction %}
  {% endunless %}

  {% 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
Number of days to wait between emails
1
Send the first email when the order is created
true
Email subject
Don't forget! Order ORDER_NAME still needs to be paid
Email body
Hi CUSTOMER_FIRST_NAME,

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

Thanks,
{{ shop.name }}