> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: updateLineItemsQuantity(_id: string, lineItems: Array) # Method package: wixEcomBackend # Method menu location: wixEcomBackend --> checkout --> updateLineItemsQuantity # Method Link: https://dev.wix.com/docs/velo/apis/wix-ecom-backend/checkout/update-line-items-quantity.md # Method Description: 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()`](#removelineitems). To add a new line item to the checkout, use [`addToCheckout()`](#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. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Update the quantity of line items in a checkout ```javascript 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" * } * } * } */ ``` ## Update the quantity of line items in a checkout (export from backend code) ```javascript import { Permissions, webMethod } from 'wix-web-module'; 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 const myUpdateQuantityFunction = webMethod(Permissions.Anyone, async (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" * } * } * } */ ``` ---