Send New Order Email

amerta


amerta / amerta/payload/utilities/emails/sendOrderEmail / sendNewOrderEmail

Function: sendNewOrderEmail()

sendNewOrderEmail(customer, order, withAdmin?): Promise<void>

Defined in: amerta/payload/utilities/emails/sendOrderEmail.ts:28

Sends a new order notification email to both admin and customer.

This function sends two emails:

  1. An admin notification email to alert site administrators of a new order
  2. A customer confirmation email with order details

Both emails are generated using templated email services and sent asynchronously. Any errors during email sending are silently caught and ignored to prevent order creation failures due to email delivery issues.

Parameters

| Parameter | Type | Default value | Description | | ------ | ------ | ------ | ------ | | customer | Customer | undefined | The customer who placed the order | | order | Order | undefined | The newly created order object containing order data | | withAdmin | boolean | true | - |

Returns

Promise<void>

Async

Example

const customer: Customer = { id: '123', email: 'user@example.com', ... };
const order: Order = { id: 'order-123', total: 100, ... };
await sendNewOrderEmail(customer, order);