Updates the quantity of one or more line items in a checkout.
This endpoint is only for updating the quantity of line items. To entirely remove a line item from
the checkout, use removeLineItems()
.
To add a new line item to the checkout, use addToCheckout()
.
This endpoint checks the amount of stock remaining for this line item. If the specified quantity
is greater than the remaining stock, then the quantity
returned in the response is the total amount
of remaining stock.
function updateLineItemsQuantity(
_id: string,
lineItems: Array<LineItemQuantityUpdate>,
): Promise<UpdateLineItemsQuantityResponse>;
Checkout ID.
Line item info to update.
import { checkout } from "wix-ecom-backend";
/* Sample checkoutId value: '21fe558e-21a0-4cff-a49b-a4ccb0f7414d'
*
* Sample listItems value:
* {
* _id: '00000000-0000-0000-0000-000000000001',
* quantity: 10
* }
*/
export async function myUpdateQuantityFunction(checkoutId, lineItems) {
try {
const updatedCheckout = await checkout.updateLineItemsQuantity(
checkoutId,
lineItems,
);
const firstUpdatedLineItem = updatedCheckout.checkout.lineItems[0];
const updatedQuantity = firstUpdatedLineItem.quantity;
console.log(
"Success! The updated quantity for the first line item is:",
updatedQuantity,
);
return updatedCheckout;
} catch (error) {
console.error(error);
}
}
/* Promise resolves to:
* {
* "checkout": {
* "_id": "21fe558e-21a0-4cff-a49b-a4ccb0f7414d",
* "lineItems": [
* {
* "_id": "00000000-0000-0000-0000-000000000001",
* "quantity": 10,
* "catalogReference": {
* "catalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a",
* "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e"
* },
* "productName": {
* "original": "Shirt",
* "translated": "Shirt"
* },
* "url": "https://example.wixsite.com/product-page/shirt",
* "price": {
* "amount": "10",
* "convertedAmount": "10",
* "formattedAmount": "$10.00",
* "formattedConvertedAmount": "$10.00"
* },
* "lineItemPrice": {
* "amount": "100",
* "convertedAmount": "100",
* "formattedAmount": "$100.00",
* "formattedConvertedAmount": "$100.00"
* },
* "fullPrice": {
* "amount": "10",
* "convertedAmount": "10",
* "formattedAmount": "$10.00",
* "formattedConvertedAmount": "$10.00"
* },
* "priceBeforeDiscounts": {
* "amount": "10",
* "convertedAmount": "10",
* "formattedAmount": "$10.00",
* "formattedConvertedAmount": "$10.00"
* },
* "totalPriceAfterTax": {
* "amount": "100",
* "convertedAmount": "100",
* "formattedAmount": "$100.00",
* "formattedConvertedAmount": "$100.00"
* },
* "totalPriceBeforeTax": {
* "amount": "100",
* "convertedAmount": "100",
* "formattedAmount": "$100.00",
* "formattedConvertedAmount": "$100.00"
* },
* "taxDetails": {
* "taxableAmount": {
* "amount": "100",
* "convertedAmount": "100",
* "formattedAmount": "$100.00",
* "formattedConvertedAmount": "$100.00"
* },
* "taxRate": "0",
* "totalTax": {
* "amount": "0",
* "convertedAmount": "0",
* "formattedAmount": "$0.00",
* "formattedConvertedAmount": "$0.00"
* },
* "rateBreakdown": []
* },
* "discount": {
* "amount": "0",
* "convertedAmount": "0",
* "formattedAmount": "$0.00",
* "formattedConvertedAmount": "$0.00"
* },
* "descriptionLines": [],
* "media": "wix:image://v1/3c76e2_c5331f937348492a97df87b0a3b34ea4~mv2.jpg/3c76e2_c5331f937348492a97df87b0a3b34ea4~mv2.jpg#originWidth=1000&originHeight=1000",
* "availability": {
* "status": "AVAILABLE"
* },
* "physicalProperties": {
* "sku": "364115376135191",
* "shippable": true
* },
* "couponScopes": [
* {
* "namespace": "stores",
* "group": {
* "name": "collection",
* "entityId": "00000000-000000-000000-000000000001"
* }
* },
* {
* "namespace": "stores",
* "group": {
* "name": "product",
* "entityId": "c8539b66-7a44-fe18-affc-afec4be8562a"
* }
* }
* ],
* "itemType": {
* "preset": "PHYSICAL"
* },
* "paymentOption": "FULL_PAYMENT_ONLINE",
* "rootCatalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a"
* }
* ],
* "shippingInfo": {
* "carrierServiceOptions": []
* },
* "buyerNote": "Updated note.",
* "buyerInfo": {
* "contactId": "a4bc8d90-a91b-467f-a775-77d65dd0442e",
* "email": "testing3@example.com",
* "memberId": "ea3d74df-b7dc-4ca1-a7c9-c416b9017a86"
* },
* "conversionCurrency": "USD",
* "priceSummary": {
* "subtotal": {
* "amount": "100",
* "convertedAmount": "100",
* "formattedAmount": "$100.00",
* "formattedConvertedAmount": "$100.00"
* },
* "shipping": {
* "amount": "0",
* "convertedAmount": "0",
* "formattedAmount": "$0.00",
* "formattedConvertedAmount": "$0.00"
* },
* "tax": {
* "amount": "0",
* "convertedAmount": "0",
* "formattedAmount": "$0.00",
* "formattedConvertedAmount": "$0.00"
* },
* "discount": {
* "amount": "0",
* "convertedAmount": "0",
* "formattedAmount": "$0.00",
* "formattedConvertedAmount": "$0.00"
* },
* "total": {
* "amount": "100",
* "convertedAmount": "100",
* "formattedAmount": "$100.00",
* "formattedConvertedAmount": "$100.00"
* },
* "additionalFees": {
* "amount": "0",
* "convertedAmount": "0",
* "formattedAmount": "$0.00",
* "formattedConvertedAmount": "$0.00"
* }
* },
* "calculationErrors": {
* "orderValidationErrors": []
* },
* "appliedDiscounts": [],
* "customFields": [],
* "weightUnit": "LB",
* "currency": "USD",
* "channelType": "WEB",
* "siteLanguage": "en",
* "buyerLanguage": "en",
* "completed": false,
* "taxIncludedInPrice": false,
* "createdBy": {
* "memberId": "ea3d74df-b7dc-4ca1-a7c9-c416b9017a86"
* },
* "_createdDate": "2023-02-22T15:49:04.627Z",
* "_updatedDate": "2023-04-30T05:51:13.309Z",
* "payNow": {
* "subtotal": {
* "amount": "100",
* "convertedAmount": "100",
* "formattedAmount": "$100.00",
* "formattedConvertedAmount": "$100.00"
* },
* "shipping": {
* "amount": "0",
* "convertedAmount": "0",
* "formattedAmount": "$0.00",
* "formattedConvertedAmount": "$0.00"
* },
* "tax": {
* "amount": "0",
* "convertedAmount": "0",
* "formattedAmount": "$0.00",
* "formattedConvertedAmount": "$0.00"
* },
* "discount": {
* "amount": "0",
* "convertedAmount": "0",
* "formattedAmount": "$0.00",
* "formattedConvertedAmount": "$0.00"
* },
* "total": {
* "amount": "100",
* "convertedAmount": "100",
* "formattedAmount": "$100.00",
* "formattedConvertedAmount": "$100.00"
* },
* "additionalFees": {
* "amount": "0",
* "convertedAmount": "0",
* "formattedAmount": "$0.00",
* "formattedConvertedAmount": "$0.00"
* }
* },
* "payLater": {
* "subtotal": {
* "amount": "0",
* "convertedAmount": "0",
* "formattedAmount": "$0.00",
* "formattedConvertedAmount": "$0.00"
* },
* "shipping": {
* "amount": "0",
* "convertedAmount": "0",
* "formattedAmount": "$0.00",
* "formattedConvertedAmount": "$0.00"
* },
* "tax": {
* "amount": "0",
* "convertedAmount": "0",
* "formattedAmount": "$0.00",
* "formattedConvertedAmount": "$0.00"
* },
* "discount": {
* "amount": "0",
* "convertedAmount": "0",
* "formattedAmount": "$0.00",
* "formattedConvertedAmount": "$0.00"
* },
* "total": {
* "amount": "0",
* "convertedAmount": "0",
* "formattedAmount": "$0.00",
* "formattedConvertedAmount": "$0.00"
* },
* "additionalFees": {
* "amount": "0",
* "convertedAmount": "0",
* "formattedAmount": "$0.00",
* "formattedConvertedAmount": "$0.00"
* }
* },
* "membershipOptions": {
* "eligibleMemberships": [],
* "invalidMemberships": [],
* "selectedMemberships": {
* "memberships": []
* }
* },
* "additionalFees": [],
* "payNowTotalAfterGiftCard": {
* "amount": "100",
* "convertedAmount": "100",
* "formattedAmount": "$100.00",
* "formattedConvertedAmount": "$100.00"
* }
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.