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;
orderId?: string;
locationId?: string;
}
fulfillment
is aCartFulfillment
object which is covered inaddItem
. Again a reminder that you need to explicitly include all the properties on theCartFulfillment
object that you’re replacing with. If the optional values are not provided, then the SDK will populate them with the defaults as covered inaddItem
.orderId
is the ID of the order you’re updating. It is only needed if you’re managing multiple orders. Otherwise exclude the field, and the SDK will use the existing order from your cookies.locationId
is 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
.