Search.../

sendFulfillmentEmail( )

Sends a fulfillment email to a specified custom fulfiller of a line item in a given order.

Description

The sendFulfillmentEmail() function returns a Promise that is resolved when the fulfillment email for the specified order is sent to the specified custom fulfiller. A custom fulfiller is a fulfiller that is not integrated with the Wix App Market. Learn more about Connecting Your Wix Store to a Fulfillment Service.

Syntax

function sendFulfillmentEmail(orderId: string, fulfillerId: string): Promise<void>

sendFulfillmentEmail Parameters

NAME
TYPE
DESCRIPTION
orderId
string

ID of the order for fulfillment.

fulfillerId
string

ID of the custom fulfiller.

Returns

Fulfilled - When the fulfillment email is sent.

Return Type:

Promise<void>

Was this helpful?

Send a fulfillment email to a custom fulfiller

Copy Code
1/***********************************
2 * Backend code - fulfillments.jsw *
3 ***********************************/
4
5import wixStoresBackend from 'wix-stores-backend';
6
7export function sendFulfillmentEmail(orderId, fulfillerId) {
8 return wixStoresBackend.sendFulfillmentEmail(orderId, fulfillerId);
9}
10
11/**************
12 * Page code *
13 **************/
14
15import { sendFulfillmentEmail } from 'backend/fulfillments';
16
17export function button1_click(event) {
18 $w("#thankYouPage1").getOrder()
19 .then((order) => {
20 sendFulfillmentEmail(order._id, order.lineItems[0].fulfillerId)
21 .then(() => {
22 // Fulfillment email sent
23 })
24 .catch((error) => {
25 // Fulfillment email not sent
26 console.log(error);
27 });
28 });
29}
Send a fulfillment email to fulfillers of unfulfilled orders

Copy Code
1import wixStoresBackend from 'wix-stores-backend';
2import wixData from 'wix-data';
3
4wixData.query("Stores/Orders")
5 // Find all unfulfilled orders
6 .eq("fulfillmentStatus", "NOT_FULFILLED")
7 .find()
8 .then((results) => {
9 const unfulfilledOrders = results.items;
10 unfulfilledOrders.forEach((order) => {
11 // Find unfulfilled orders with line items associated with a custom fulfiller (have a fulfillerId)
12 const fulfillerIds = order.lineItems.map(lineItem => lineItem.fulfillerId);
13 fulfillerIds.forEach((fulfillerId) => {
14 if (order._id && fulfillerId) {
15 // Send a fulfillment email to each unfulfilled custom fulfiller
16 wixStoresBackend.sendFulfillmentEmail(order._id, fulfillerId)
17 .then(() => {
18 // Fulfillment email sent
19 })
20 .catch((error) => {
21 // Fulfillment email not sent
22 console.log(error);
23 });
24 };
25 });
26 });
27 })