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): Promise<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>
NAME
TYPE
DESCRIPTION
id
string
ID for the newly created fulfillment.
order
Order
Updated order.
Was this helpful?
Create a new fulfillment
Copy Code
1import wixStoresBackend from 'wix-stores-backend'23const fulfillment = {4 "lineItems": [{ "index": 1, "quantity": 1 }],5 "trackingInfo": {6 "shippingProvider": "fedex",7 "trackingLink": "https://www.fedex.com/apps/fedextrack/?action=track&trackingnumber=12345",8 "trackingNumber": "12345"9 }10}1112export function createFulfillment(orderId) {13 return wixStoresBackend.createFulfillment(orderId, fulfillment)14 .then((updatedOrder) => {15 // Fulfillment created16 const fulfillmentId = updatedOrder.id17 const orderId = updatedOrder.order._id18 const fulfillmentStatus = updatedOrder.order.fulfillmentStatus19 })20 .catch(error => {21 // Fulfillment not created22 console.error(error)23 })24}2526/* 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 * "shippingRegion": "Domestic",89 * "shipmentDetails": {90 * "address": {91 * "formatted": "company name\n235 W 23rd St\nNew York, New York 10011\nUnited States\n5555555555",92 * "city": "New York",93 * "country": "USA",94 * "addressLine": "235 W 23rd St",95 * "postalCode": "10011",96 * "subdivision": "NY"97 * },98 * "firstName": "John",99 * "lastName": "Doe",100 * "email": "john.doe@somedomain.com",101 * "phone": "5555555555",102 * "company": "company name",103 * "tax": 0,104 * "discount": 0,105 * "priceData": null106 * },107 * "pickupDetails": null108 * },109 * "lineItems": [110 * {111 * "index": 1,112 * "quantity": 1,113 * "price": 5,114 * "name": "my product's name",115 * "translatedName": "Nombre traducido",116 * "productId": "3fb6a3c8-988b-8755-04bd-5c59ae0b18ea",117 * "totalPrice": 5,118 * "lineItemType": "PHYSICAL",119 * "options": [120 * {121 * "option": "Size",122 * "selection": "Medium"123 * }124 * ],125 * "customTextFields": [126 * {127 * "title": "Notes for delivery",128 * "value": "Please leave at front door"129 * }130 * ],131 * "weight": 1.42,132 * "sku": "36523641234523",133 * "discount": 0,134 * "tax": 5,135 * "taxIncludedInPrice": true,136 * "priceData": {137 * "price": "5",138 * "totalPrice": 5,139 * "taxIncludedInPrice": true140 * },141 * "mediaItem": null142 * }143 * ],144 * "totals": {145 * "discount": 0,146 * "quantity": 1,147 * "shipping": 0,148 * "subtotal": 5,149 * "tax": 0,150 * "total": 5,151 * "weight": 1.42152 * },153 * "weightUnit": "KG",154 * "customField": {155 * "value": "Please call when outside",156 * "title": "Notes for delivery",157 * "translatedTitle": "Notas de entrega"158 * },159 * "fulfillments": [160 * {161 * "id": "cfbc5122-8766-4209-8bf4-611a10f9c546",162 * "dateCreated": "2020-06-10T15:38:10.938Z",163 * "lineItems": [164 * {165 * "index": 1,166 * "quantity": 1167 * }168 * ],169 * "trackingInfo": {170 * "trackingNumber": "12345",171 * "shippingProvider": "fedex",172 * "trackingLink": "https://www.fedex.com/apps/fedextrack/?action=track&trackingnumber=12345"173 * },174 * }175 * ],176 * "discount": null177 * }178 * }179 *180 */