Resending customer invite uses outdated template

Resending customer invite uses outdated template

MoritzR
Shopify Partner
2 0 0

We are giving customers the possibility to create accounts for which we require confirmation via an activation link, using the Customers API: https://shopify.dev/api/admin-rest/2022-07/resources/customer, like this:

 

 

const createCustomerBody = {
  customer: {
    email: email,
    firstName: firstName,
    lastName: lastName,
    send_email_invite: true
  }
};

const headers = {
  Authorization: `BASIC ${token}`
};

const response = await (await fetch(
  `https://${our-store}.myshopify.com/admin/api/2022-07/customers.json`,
  {
    method: 'POST',
    headers: headers,
    body: JSON.stringify(createCustomerBody)
  }
)).json();

 

 

 
A new customer would then receive the invitation e-mail created with the customer invitation e-mail template defined in our store.

If a customer with that e-mail address already exists, this would give an error response, indicating that the e-mail address has already been taken. In that case we resend the invitation like so (by getting the customer id and using the `send_invite` API method:


 

 

if (response?.errors?.email === 'has already been taken') {
  const found = await (await fetch(
    `https://${ourStore}.myshopify.com/admin/api/2021-07/customers/search.json?query=${email}&fields=id`,
    {
      method: 'GET',
      headers
    }
  )).json();
  const customerId = found.customers[0].id;

  const inviteSent = await (await fetch(
    `https://${ourStore}.myshopify.com/admin/api/2021-07/customers/${customerId}/send_invite.json`,
    {
      method: 'POST',
      headers
    }
  )).json();
}

 

 

 
So far, so good. But our invitation template has changed some time in the past. And customers who were sent an invitation before that but did not activate successfully afterwards still receive the e-mail with the old invitation template.

We would like that invitations be sent out using the current up-to-date invitation template, because the old template is outdated and contains a link to a page for activation which does not work.

How can we achieve this?

Replies 0 (0)