Search.../

createFulfillment( )

Creates a new fulfillment in an order.

Description

The createFulfillment() function returns a Promise that is resolved to an object with the fulfillmentId and the updated Order when the fulfillment is created.

Syntax

function createFulfillment(orderId: string, fulfillment: FulfillmentInfo): NewFulfillmentAndOrder

createFulfillment Parameters

NAME
TYPE
DESCRIPTION
orderId

string

ID of the order to create the fulfillment in.

fulfillment

FulfillmentInfo

Fulfillment information.

Returns

Fulfilled - Information about the new fulfillment and the updated order.

Return Type:

Promise<NewFulfillmentAndOrder>

Was this helpful?

Create a new fulfillment

Code Example

Copy Code
1import wixStoresBackend from 'wix-stores-backend'
2
3export function createFulfillment(orderId) {
4 return wixStoresBackend.createFulfillment(
5 orderId,
6 {
7 "fulfillment": {
8 "lineItems": [{ "index": 1, "quantity": 1 }],
9 "trackingInfo": {
10 "shippingProvider": "fedex",
11 "trackingLink": "https://www.fedex.com/apps/fedextrack/?action=track&trackingnumber=12345",
12 "trackingNumber": "12345"
13 }
14 }
15 })
16 .then((newFulfillment) => {
17 // Fulfillment created
18 const fulfillmentId = newFulfillment.id
19 const fulfillmentStatus = newFulfillment.order.fulfillmentStatus
20 })
21 .catch(error => {
22 // Fulfillment not created
23 })
24}
25
26/* Returns a promise that resolves to:
27 *
28 * {
29 * "id": "75159953-1234-4490-9b4a-9301f9264427",
30 * "order": {
31 * "_id": "d5d43d01-d9a4-4cc2-b257-61184b881447",
32 * "_updatedDate": "2020-05-27T12:20:37.994Z",
33 * "buyerLanguage": "en",
34 * "channelInfo": {
35 * "type": "WEB"
36 * },
37 * "enteredBy": {
38 * "id": "f6c2c0f9-4e9f-a58d-a02d-9af2497294d9",
39 * "identityType": "MEMBER"
40 * },
41 * "billingInfo": {
42 * "address": {
43 * "formatted": "My company name\n235 W 23rd St\nNew York, New York 10011\nUnited States\n+15555555555",
44 * "city": "New York",
45 * "country": "USA",
46 * "addressLine": "235 W 23rd St",
47 * "postalCode": "10011",
48 * "subdivision": "NY"
49 * },
50 * "firstName": "John",
51 * "lastName": "Doe",
52 * "email": "john.doe@somedomain.com",
53 * "phone": "+15555555555",
54 * "company": "My company name",
55 * "externalTransactionId": "7c03ca74-eaf5-4541-8678-9b857634fdcb",
56 * "paidDate": "2020-05-27T12:20:37.994Z",
57 * "paymentMethod": "VISA",
58 * "paymentGatewayTransactionId": "29A06193U6234935D",
59 * "paymentProviderTransactionId": "7c03ca74-eaf5-4541-8678-9b857634fdcb"
60 * },
61 * "buyerInfo": {
62 * "id": "f6c2c0f9-4e9f-a58d-a02d-9af2497294d9",
63 * "identityType": "MEMBER",
64 * "firstName": "John",
65 * "lastName": "Doe",
66 * "phone": "+15555555555",
67 * "email": "john.doe@somedomain.com"
68 * },
69 * "_dateCreated": "2020-05-27T12:20:37.966Z",
70 * "currency": "ILS",
71 * "fulfillmentStatus": "FULFILLED",
72 * "archived": false,
73 * "activities": [
74 * {
75 * "type": "ORDER_PLACED",
76 * "timestamp": "2020-05-27T12:20:37.966Z"
77 * },
78 * {
79 * "type": "ORDER_PAID",
80 * "timestamp": "2020-05-27T12:20:37.994Z"
81 * }
82 * ],
83 * "number": 10019,
84 * "paymentStatus": "PAID",
85 * "shippingInfo": {
86 * "deliveryOption": "Free Shipping",
87 * "estimatedDeliveryTime": "4:30pm",
88 * "shipmentDetails": {
89 * "address": {
90 * "formatted": "company name\n235 W 23rd St\nNew York, New York 10011\nUnited States\n5555555555",
91 * "city": "New York",
92 * "country": "USA",
93 * "addressLine": "235 W 23rd St",
94 * "postalCode": "10011",
95 * "subdivision": "NY"
96 * },
97 * "firstName": "John",
98 * "lastName": "Doe",
99 * "email": "john.doe@somedomain.com",
100 * "phone": "5555555555",
101 * "company": "company name",
102 * "tax": 0,
103 * "discount": 0,
104 * "priceData": null
105 * },
106 * "pickupDetails": null
107 * },
108 * "lineItems": [
109 * {
110 * "index": 1,
111 * "quantity": 1,
112 * "price": 5,
113 * "name": "my product's name",
114 * "translatedName": "Nombre traducido",
115 * "productId": "3fb6a3c8-988b-8755-04bd-5c59ae0b18ea",
116 * "totalPrice": 5,
117 * "lineItemType": "PHYSICAL",
118 * "options": [
119 * {
120 * "option": "Size",
121 * "selection": "Medium"
122 * }
123 * ],
124 * "customTextFields": [
125 * {
126 * "title": "Notes for delivery",
127 * "value": "Please leave at front door"
128 * }
129 * ],
130 * "weight": 1.42,
131 * "sku": "36523641234523",
132 * "discount": 0,
133 * "tax": 5,
134 * "taxIncludedInPrice": true,
135 * "priceData": {
136 * "price": "5",
137 * "totalPrice": 5,
138 * "taxIncludedInPrice": true
139 * },
140 * "mediaItem": null
141 * }
142 * ],
143 * "totals": {
144 * "discount": 0,
145 * "quantity": 1,
146 * "shipping": 0,
147 * "subtotal": 5,
148 * "tax": 0,
149 * "total": 5,
150 * "weight": 1.42
151 * },
152 * "weightUnit": "KG",
153 * "customField": {
154 * "value": "Please call when outside",
155 * "title": "Notes for delivery",
156 * "translatedTitle": "Notas de entrega"
157 * },
158 * "fulfillments": [
159 * {
160 * "id": "cfbc5122-8766-4209-8bf4-611a10f9c546",
161 * "dateCreated": "2020-06-10T15:38:10.938Z",
162 * "lineItems": [
163 * {
164 * "index": 1,
165 * "quantity": 1
166 * }
167 * ],
168 * "trackingInfo": {
169 * "trackingNumber": "12345",
170 * "shippingProvider": "fedex",
171 * "trackingLink": "https://www.fedex.com/apps/fedextrack/?action=track&trackingnumber=12345"
172 * },
173 * }
174 * ],
175 * "discount": null
176 * }
177 * }
178 *
179 */