Send customers a reorder link X days after ordering, with Mechanic.

Mechanic is an automation development platform for Shopify. :)

Send customers a reorder link X days after ordering

by Isaac Bowen (team@usemechanic.com)

Use this task to make repeat business easy. Set the number of days to wait, then let this task automatically email your customers a one-click reorder link X days after their purchase, sending them straight to checkout with their entire cart pre-filled.

Runs 30 days after an order is paid. Configuration includes order referral code, email subject, email body, and days to wait.

15-day free trial – unlimited tasks

Documentation

Tip: Fill in the "Order referral code" option to enable order conversion tracking for this task's emails. (Learn more about conversion tracking with order links.)

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
30 days after an order is paid (shopify/orders/paid+30.days)
Options
order referral code, email subject (required), email body (multiline, required), days to wait (number, required)
Script
{% assign order = order.reload %}

{% if event.preview or order.email != blank %}
  {% assign variant_string = "" %}

  {% for line_item in order.line_items %}
    {% if line_item.variant_id %}
      {% capture variant_string %}{% if variant_string != blank %}{{ variant_string }},{% endif %}{{ line_item.variant_id }}:{{ line_item.quantity }}{% endcapture %}
    {% endif %}
  {% endfor %}

  {% if event.preview and variant_string == blank %}
    {% assign variant_string = "1234567890:1,0987654321:2" %}
  {% endif %}

  {% if variant_string != blank %}
    {% capture reorder_url %}https://{{ shop.domain }}/cart/{{ variant_string }}?{% if options.order_referral_code != blank %}ref={{ options.order_referral_code | url_param_escape }}&{% endif %}checkout[email]={{ order.email | url_param_escape }}{% endcapture %}

    {
      "action": {
        "type": "email",
        "options": {
          "to": {{ order.email | json }},
          "subject": {{ options.email_subject__required | strip | json }},
          "body": {{ options.email_body__multiline_required | replace: "REORDER_URL", reorder_url | strip | newline_to_br | json }},
          "reply_to": {{ shop.customer_email | json }},
          "from_display_name": {{ shop.name | json }}
        }
      }
    }
  {% endif %}
{% 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
Would you like to order again?
Email body
Hello,

Thanks for your order! Use this link to reorder in just a couple clicks:

<b><a href="REORDER_URL">Reorder now</a></b>

Cheers,
{{ shop.name }}