Send account invites to all customers in bulk, with Mechanic.

Mechanic is a development platform for Shopify. :)

Send account invites to all customers in bulk

by Isaac Bowen (team@usemechanic.com)

Use this task to send out account invitations to all the customers you already have on file, with the push of a button. Optionally, filter by customer tag.

Runs when a user triggers the task. Configuration includes only invite customers with this tag, custom subject, and custom message.

15-day free trial – unlimited tasks

Documentation

This task sends the same Shopify-powered emails that are used when sending individual customer invitations (see Shopify's documentation), and uses the same Shopify email template. A custom subject and message are not required, but will be included when specified.

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 a user triggers the task (mechanic/user/trigger)
Options
only invite customers with this tag, custom subject, custom message (multiline)
Script
{% assign customers = shop.customers %}

{% if options.only_invite_customers_with_this_tag != blank %}
  {% assign query = "tag:" | append: options.only_invite_customers_with_this_tag %}
  {% assign customers = shop.customers.search[query] %}
{% endif %}

{% if event.preview %}
  {% assign customers = array %}
  {% assign customers[0] = hash %}
  {% assign customers[0]["id"] = 12345 %}
{% endif %}

{% for customer in customers %}
  {% if customer.state == "enabled" %}
    {% continue %}
  {% endif %}

  {% action "shopify" %}
    [
      "post",
      "/admin/customers/{{ customer.id }}/send_invite.json",
      {
        "customer_invite": {
          "subject": {{ options.custom_subject | json }},
          "custom_message": {{ options.custom_message__multiline | json }}
        }
      }
    ]
  {% endaction %}
{% endfor %}
Mechanic tasks are written in Liquid, which makes them easy to write and easy to modify. Learn more about our platform.