> 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 --> cart --> updateLineItemsQuantity # Method Link: https://dev.wix.com/docs/velo/apis/wix-ecom-backend/cart/update-line-items-quantity.md # Method Description: Updates the quantity of 1 or more line items in a cart. The `updateLineItemsQuantity()` function returns a Promise that resolves when the quantities of the specified cart's line items are updated. This endpoint is only for updating the quantity of line items. To entirely remove a line item from the cart, use [`removeLineItems()`](#removelineitems). To add a new line item to the cart, use [`addToCart()`](#addtocart). 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. > **Note:** After a cart is updated, call [Refresh Cart](https://dev.wix.com/docs/velo/apis/wix-ecom-frontend/refresh-cart.md) to update the cart's UI elements and trigger the Cart Updated event. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Update the quantity of a cart's line items ```javascript /***************************************** * Backend code - my-backend-file.web.js * *****************************************/ import { Permissions, webMethod } from 'wix-web-module'; import { cart } from 'wix-ecom-backend'; export const myUpdateLineItemsQuantityFunction = webMethod(Permissions.Anyone, async (cartId, lineItems) => { try { const updatedCart = await cart.updateLineItemsQuantity(cartId, lineItems); console.log('Success! Line item quantities updated:', updatedCart); return updatedCart; } catch (error) { console.error(error); // Handle the error } }); /************* * Page code * *************/ import wixEcomFrontend from 'wix-ecom-frontend'; import { myUpdateLineItemsQuantityFunction } from 'backend/my-backend-file.web'; // Sample cartId: const cartId = 'b79fd177-ec98-4245-b9f6-f09e7afa9d04'; // Sample lineItems array: const lineItems = [ { "_id": '00000000-0000-0000-0000-000000000001', "quantity": 2 }, { "_id": '00000000-0000-0000-0000-000000000002', "quantity": 3 } ] const updatedCart = await myUpdateLineItemsQuantityFunction(cartId, lineItems); // Refresh the cart after adding item. await wixEcomFrontend.refreshCart(); // Navigate to the cart page. await wixEcomFrontend.navigateToCartPage(); /* Updated cart: * * { * "_id": "b79fd177-ec98-4245-b9f6-f09e7afa9d04", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000001", * "quantity": 2, * "catalogReference": { * "catalogItemId": "df19c1f7-07d8-a265-42f8-e8dfa824cc6e", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", * "options": { * "variantId": "e62fee23-7878-437a-bf0e-292f17d11cb5" * } * }, * "productName": { * "original": "Shoe", * "translated": "Shoe" * }, * "url": "https://example.wixsite.com", * "price": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "€85.00", * "formattedConvertedAmount": "€85.00" * }, * "fullPrice": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "€85.00", * "formattedConvertedAmount": "€85.00" * }, * "priceBeforeDiscounts": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "€85.00", * "formattedConvertedAmount": "€85.00" * }, * "descriptionLines": [ * { * "name": { * "original": "Color", * "translated": "Color" * }, * "colorInfo": { * "original": "Black", * "translated": "Black", * "code": "#000" * }, * "lineType": "UNRECOGNISED" * } * ], * "image": "wix:image://v1/3c76e2_bf235c38610f4d2a905db71095b351cf~mv2.jpg#originWidth=1000&originHeight=1000", * "availability": { * "status": "AVAILABLE", * "quantityAvailable": 30 * }, * "physicalProperties": { * "sku": "364215376135191", * "shippable": true * }, * "couponScopes": [ * { * "namespace": "stores", * "group": { * "name": "collection", * "entityId": "00000000-000000-000000-000000000001" * } * }, * { * "namespace": "stores", * "group": { * "name": "product", * "entityId": "df19c1f7-07d8-a265-42f8-e8dfa824cc6e" * } * } * ], * "itemType": { * "preset": "PHYSICAL" * }, * "paymentOption": "FULL_PAYMENT_ONLINE" * }, * { * "_id": "00000000-0000-0000-0000-000000000002", * "quantity": 3, * "catalogReference": { * "catalogItemId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", * "options": { * "variantId": "132b84e8-aab8-47a1-a1f6-2c47557b64a4" * } * }, * "productName": { * "original": "Watch", * "translated": "Watch" * }, * "url": "https://example.wixsite.com", * "price": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "€30.00", * "formattedConvertedAmount": "€30.00" * }, * "fullPrice": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "€30.00", * "formattedConvertedAmount": "€30.00" * }, * "priceBeforeDiscounts": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "€30.00", * "formattedConvertedAmount": "€30.00" * }, * "descriptionLines": [ * { * "name": { * "original": "Size", * "translated": "Size" * }, * "plainText": { * "original": "Medium", * "translated": "Medium" * }, * "lineType": "UNRECOGNISED" * }, * { * "name": { * "original": "Color", * "translated": "Color" * }, * "colorInfo": { * "original": "Grey", * "translated": "Grey", * "code": "rgb(128, 128, 128)" * }, * "lineType": "UNRECOGNISED" * } * ], * "image": "wix:image://v1/3c76e2_8891bbe3372a428aac976ac59aa0ac74~mv2.jpg#originWidth=1000&originHeight=1000", * "availability": { * "status": "AVAILABLE" * }, * "physicalProperties": { * "sku": "217537123517253", * "shippable": true * }, * "couponScopes": [ * { * "namespace": "stores", * "group": { * "name": "collection", * "entityId": "00000000-000000-000000-000000000001" * } * }, * { * "namespace": "stores", * "group": { * "name": "product", * "entityId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09" * } * } * ], * "itemType": { * "preset": "PHYSICAL" * }, * "paymentOption": "FULL_PAYMENT_ONLINE" * } * ], * "buyerInfo": { * "visitorId": "4c7ce95c-9fb3-417d-9f02-b41e82b841f7" * }, * "currency": "EUR", * "conversionCurrency": "EUR", * "buyerLanguage": "en", * "siteLanguage": "en", * "taxIncludedInPrices": false, * "weightUnit": "KG", * "subtotal": { * "amount": "260", * "convertedAmount": "260", * "formattedAmount": "€260.00", * "formattedConvertedAmount": "€260.00" * }, * "appliedDiscounts": [], * "inSync": false, * "_createdDate": "2022-06-22T11:32:29.601Z", * "_updatedDate": "2022-06-22T11:36:48.831Z" * } * */ ``` ---