Mechanic is a development and ecommerce automation platform for Shopify. :)
This task sends account invitations to newly-created customers, whether created/imported through the Shopify admin or through another app. It does not send invitation emails for customers without an email address, or to customers who've signed up via your online store.
Runs Occurs whenever a customer is created, with a 1 minute delay. Configuration includes invitation email subject and invitation email body.
This task sends account invitations to newly-created customers, whether created/imported through the Shopify admin or through another app. It does not send invitation emails for customers without an email address, or to customers who've signed up via your online store.
(Wondering about the 1-minute delay? It's because customers who sign themselves up aren't marked as such until a few seconds after their account is created. So, Mechanic waits a minute, just to be sure.)
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?)
shopify/customers/create+1.minute
{% assign invitation_email_subject = options.invitation_email_subject__required %}
{% assign invitation_email_body = options.invitation_email_body__multiline_required %}
{% if event.topic == "shopify/customers/create" %}
{% comment %}
-- get customer data
{% endcomment %}
{% capture query %}
query {
customer(id: {{ customer.admin_graphql_api_id | json }}) {
id
displayName
defaultEmailAddress {
emailAddress
}
state
tags
}
}
{% endcapture %}
{% assign result = query | shopify %}
{% if event.preview %}
{% capture result_json %}
{
"data": {
"customer": {
"id": "gid://shopify/Customer/1234567890",
"state": "DISABLED"
}
}
}
{% endcapture %}
{% assign result = result_json | parse_json %}
{% endif %}
{% assign customer = result.data.customer %}
{% unless event.preview %}
{% log customer: customer %}
{% endunless %}
{% unless customer.state == "DISABLED" %}
{% log "Customer state is not 'DISABLED', so an account invite will not be sent." %}
{% break %}
{% endunless %}
{% action "shopify" %}
mutation {
customerSendAccountInviteEmail(
customerId: {{ customer.id | json }}
email: {
subject: {{ invitation_email_subject | json }}
customMessage: {{ invitation_email_body | json }}
}
) {
customer {
id
displayName
defaultEmailAddress {
emailAddress
}
state
}
}
}
{% endaction %}
{% endif %}