update-fulfillment-preference
Method: POST
Path: /carts/{id}/fulfillment-preference
Tags: Fulfillment
Summary
Update fulfillment preference
Description
Sets the fulfillment preference on a cart. Returns a fully updated Cart object. Supported types: delivery, collect-in-store, or partial-collect-and-delivery. Requires an anonymous or signed-in bearer session. Loyalty redemption and credit balance are calculated for the customer assigned to the cart.
Storefront SDK Usage
SDK Method: sdk.cart.updateFulfillmentPreference()
Example:
// For delivery fulfillment with shipments
const { data, error } = await sdk.cart.updateFulfillmentPreference(
{ id: "01H9CART12345ABCDE" },
{
fulfillment_type: "delivery",
shipments: [
{
id: "01H9SHIP12345ABCDE",
shipping_provider_id: "01H9PROV12345FAST",
courier_company_id: "01H9COY12345FAST" // Optional
}
]
}
);
if (error) {
console.error("Failed to update fulfillment preference:", error.message);
} else {
console.log("Fulfillment preference updated:", data.cart.fulfillment_preference?.fulfillment_type);
console.log("Shipping cost:", data.cart.shipping_amount);
}
// For collect-in-store fulfillment
const { data: collectData, error: collectError } = await sdk.cart.updateFulfillmentPreference(
{ id: "01H9CART12345ABCDE" },
{
fulfillment_type: "collect-in-store",
pickup_location_id: "01H9STORE12345ABC"
}
);TypeScript Definition
"update-fulfillment-preference": {
parameters: {
query?: never;
header?: never;
path: {
/** @description Cart ID */
id: string;
};
cookie?: never;
};
requestBody: {
content: {
"application/json": components["schemas"]["FulfillmentPreference"];
};
};
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
message: string;
success: boolean;
content: {
cart: components["schemas"]["CartRead"];
};
};
};
};
/** @description The cart is missing or inactive, or the request is invalid. */
400: components["responses"]["BadRequest"];
401: components["responses"]["Unauthorized"];
403: components["responses"]["Forbidden"];
500: components["responses"]["InternalServerError"];
504: components["responses"]["GatewayTimeout"];
};
};Component References
| Reference | Resolves To |
|---|---|
components["schemas"]["FulfillmentPreference"] | FulfillmentPreference |
components["schemas"]["CartRead"] | CartRead |
components["responses"]["BadRequest"] | BadRequest |
components["responses"]["Unauthorized"] | Unauthorized |
components["responses"]["Forbidden"] | Forbidden |
components["responses"]["InternalServerError"] | InternalServerError |
components["responses"]["GatewayTimeout"] | GatewayTimeout |
Request Body
Content Types: application/json
Responses
200
OK
400
Bad request
401
Authentication failed. Codes include token-required, token-expired and token_not_valid for an invalid or expired token.
403
Access denied. token-required requires an authenticated session; permission-denied means the caller cannot access this resource. On POS, session-expired requires signing in again.
500
The request failed because of an unexpected error.
504
The request timed out.
OpenAPI Definition
{
"tags": [
"Fulfillment"
],
"operationId": "update-fulfillment-preference",
"summary": "Update fulfillment preference",
"description": "Sets the fulfillment preference on a cart. Returns a fully updated `Cart` object. Supported types: `delivery`, `collect-in-store`, or `partial-collect-and-delivery`. Requires an anonymous or signed-in bearer session. Loyalty redemption and credit balance are calculated for the customer assigned to the cart.",
"externalDocs": {
"url": "https://llm-docs.commercengine.io/storefront/operations/update-fulfillment-preference",
"description": "API reference for the update-fulfillment-preference operation"
},
"requestBody": {
"description": "",
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/FulfillmentPreference"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"message",
"success",
"content"
],
"properties": {
"message": {
"type": "string"
},
"success": {
"type": "boolean"
},
"content": {
"properties": {
"cart": {
"$ref": "#/components/schemas/CartRead"
}
},
"required": [
"cart"
],
"type": "object"
}
}
}
}
},
"links": {
"EvaluateCoupons": {
"operationId": "evaluate-coupons",
"parameters": {
"id": "$request.path.id"
},
"description": "Evaluate coupon eligibility for this cart."
},
"EvaluatePromotions": {
"operationId": "evaluate-promotions",
"parameters": {
"id": "$request.path.id"
},
"description": "Evaluate promotion eligibility for this cart."
},
"CreateOrderFromCart": {
"operationId": "create-order",
"requestBody": {
"cart_id": "$request.path.id"
},
"description": "Create an order from this cart."
}
}
},
"400": {
"description": "The cart is missing or inactive, or the request is invalid.",
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"500": {
"$ref": "#/components/responses/InternalServerError"
},
"504": {
"$ref": "#/components/responses/GatewayTimeout"
}
},
"security": [
{
"Authorization": []
}
],
"x-speakeasy-group": "carts",
"x-speakeasy-ignore": false,
"x-speakeasy-name-override": "updateFulfillmentPreference"
}Auto-generated from OpenAPI spec and TypeScript definitions