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 ***********************************/45import wixStoresBackend from 'wix-stores-backend';67export function sendFulfillmentEmail(orderId, fulfillerId) {8 return wixStoresBackend.sendFulfillmentEmail(orderId, fulfillerId);9}1011/**************12 * Page code *13 **************/1415import { sendFulfillmentEmail } from 'backend/fulfillments';1617export function button1_click(event) {18 $w("#thankYouPage1").getOrder()19 .then((order) => {20 sendFulfillmentEmail(order._id, order.lineItems[0].fulfillerId)21 .then(() => {22 // Fulfillment email sent23 })24 .catch((error) => {25 // Fulfillment email not sent26 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';34wixData.query("Stores/Orders")5 // Find all unfulfilled orders6 .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 fulfiller16 wixStoresBackend.sendFulfillmentEmail(order._id, fulfillerId)17 .then(() => {18 // Fulfillment email sent19 })20 .catch((error) => {21 // Fulfillment email not sent22 console.log(error);23 });24 };25 });26 });27 })