An event that triggers when one or more of an order's fulfillments are created, updated, or deleted.
The onFulfillmentsUpdated()
event handler runs when a fulfillment is updated. The received object contains information about the fulfillment that was updated and event metadata.
Note: Backend events don't work when previewing your site.
function wixEcom_onFulfillmentsUpdated(event: FulfillmentsUpdated): void;
Information about the fulfillments that were updated.
// Place this code in the events.js file
// of your site's Backend section.
// Add the file if it doesn't exist.
export function wixEcom_onFulfillmentsUpdated(event) {
const orderId = event.entity.orderId;
const fulfillmentId = event.entity.fulfillments[0]._id;
const eventId = event.metadata.id;
console.log("Fulfillment updated", event);
}
/* Full event object:
*
* {
* "metadata": {
* "id": "aa6bf186-a19f-4085-8726-11fde6b629f7",
* "entityId": "a6c3a817-579d-4cb5-8521-2fe53b2c4bf1",
* "eventTime": "2023-03-08T11:04:15.512044Z",
* "triggeredByAnonymizeRequest": false
* },
* "entity": {
* "orderId": "a6c3a817-579d-4cb5-8521-2fe53b2c4bf1",
* "fulfillments": [
* {
* "_id": "a838877d-3f13-49f3-ab29-1cde478e0949",
* "_createdDate": "2023-03-07T14:30:21.535Z",
* "lineItems": [
* {
* "_id": "00000000-0000-0000-0000-000000000001",
* "quantity": 1
* }
* ],
* "trackingInfo": {
* "trackingNumber": "12345",
* "shippingProvider": "usps",
* "trackingLink": "https://tools.usps.com/go/TrackConfirmAction.action?tLabels=12345"
* }
* }
* ]
* }
* }
*
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.