Put Fulfillment
putFulfillment allows you to replace the fulfillment on an order. The action taken here is similar to when you use addItem which also replaces the fulfillment.
Usage
putFulfillment takes in the following object.
interface PutFulfillmentRequest {
fulfillment: CartFulfillment;
locationId?: string;
}
fulfillmentis aCartFulfillmentobject which is covered inaddItem. Again a reminder that you need to explicitly include all the properties on theCartFulfillmentobject that you’re replacing with. If the optional values are not provided, then the SDK will populate them with the defaults as covered inaddItem.locationIdis the ID of the location for the order. It is only needed if you are changing the location of the order.
Example
The following example changes the fulfillment type to PICKUP with additional pickup details and changes the location ID of the order.
const putFulfillmentRequest = {
fulfillment: {
fulfillmentType: 'PICKUP',
pickupDetails: {
curbsidePickupRequested: true,
curbsidePickupDetails: {
curbsideDetails: 'Contactless please'
},
},
setPastTimeToCurrent: true,
},
locationId: 'LOCATION_ID'
};
try {
const response = await sdk.cart.putFulfillment(putFulfillmentRequest);
} catch (error) {
// Handle errors
}
Return Value and Error Handling
putFulfillment has the same return value and error handling that is documented for addItem.