Vendure: Notify admins on certain transactional events ( account-creation, order-confirmation etc).

Created on 25 May 2021  路  3Comments  路  Source: vendure-ecommerce/vendure

Is your feature request related to a problem? Please describe.
I would like to have an option to copy/send certain transaction emails to an array of email addresses ( admins ).

Describe the solution you'd like
As an admin of the platform, I would like to be notified when someone creates an account, or places an order. At the moment, such transactional emails are sent to the recipient in context ( user ). As an admin, I would like a copy of the email ( preferably with an option to customize admin email templates ) sent to an array of email addresses.

Describe alternatives you've considered

  • Setup nodemailer/similar separately to handle custom transaction emails outside vendure

Most helpful comment

Currently this you can implement on your own:
1) custom string (list) field for email addresses in global settings
2) either add admin addresses as recipients to customer emails (you can set multiple recipients by providing string of email addresses separated by comma e.g. "[email protected],[email protected]") or create custom email handler with custom template for admins
3) observe eventbus for any extra events you want to be notified about and trigger new email events there

You can retrieve the admin recipients in loadData method:

...
.loadData(async (context) => {
        const settings = await context.injector
            .get(TransactionalConnection)
            .getRepository(GlobalSettings)
            .findOne();
        const recipients: string = (settings?.customFields as any).adminRecipients;
        return { recipients };
})
.setRecipient((event) => event.data.recipients)
...

All 3 comments

Currently this you can implement on your own:
1) custom string (list) field for email addresses in global settings
2) either add admin addresses as recipients to customer emails (you can set multiple recipients by providing string of email addresses separated by comma e.g. "[email protected],[email protected]") or create custom email handler with custom template for admins
3) observe eventbus for any extra events you want to be notified about and trigger new email events there

You can retrieve the admin recipients in loadData method:

...
.loadData(async (context) => {
        const settings = await context.injector
            .get(TransactionalConnection)
            .getRepository(GlobalSettings)
            .findOne();
        const recipients: string = (settings?.customFields as any).adminRecipients;
        return { recipients };
})
.setRecipient((event) => event.data.recipients)
...

Thanks @chladog for your input! @azfx does this solve it for you? If so you can close the issue.

hi @chladog , thanks for the detailed solution, @michaelbromley, yes - that should definitely work, closing the issue!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

michaelbromley picture michaelbromley  路  4Comments

drewniakradoslaw picture drewniakradoslaw  路  5Comments

rcorzogutierrez picture rcorzogutierrez  路  6Comments

fmq picture fmq  路  7Comments

megataps picture megataps  路  4Comments