Search...
removeLineItems( )
Removes line items from the specified cart.
Description
The removeLineItems()
function returns a Promise that resolves to the updated cart when the line items are removed from the specified cart.
Authorization
Request
This endpoint does not take any parameters
Response Object
Fulfilled - Updated cart.
NAME
TYPE
DESCRIPTION
cart
Cart
Updated cart.
Status/Error Codes
Was this helpful?
Remove 3 line items from a cart
Copy Code
1/*****************************************2 * Backend code - my-backend-file.web.js *3 ****************************************/45import { Permissions, webMethod } from 'wix-web-module';6import { cart } from 'wix-ecom-backend';78export const myRemoveLineItemsFunction = webMethod(Permissions.Anyone, async (cartId, lineItemIds) => {9 try {10 const updatedCart = await cart.removeLineItems(cartId, lineItemIds);11 console.log('Success! Line items removed from cart:', updatedCart);12 return updatedCart;13 } catch (error) {14 console.error(error);15 // Handle the error16 }17});1819/*************20 * Page code *21 ************/2223import { myRemoveLineItemsFunction } from 'backend/my-backend-file.web';2425// Sample cartId:26const cartId = 'ba47a627-7bb8-4918-89b2-6a72af464765';2728// Sample lineItemIds array:29const lineItemIds = [30 '00000000-0000-0000-0000-000000000001',31 '00000000-0000-0000-0000-000000000002',32 '00000000-0000-0000-0000-000000000003'33]3435myRemoveLineItemsFunction(cartId, lineItemIds)36 .then((updatedCart) => {37 const cartId = updatedCart._id;38 // All lineItems removed if numberOfCartItems value is 039 const numberOfCartItems = updatedCart.lineItems.length;4041 console.log('Success! Line items removed from cart:', updatedCart);42 return updatedCart;43 })44 .catch((error) => {45 console.error(error);46 // Handle the error47 });4849/* Promise resolves to:50 *51 * {52 * "_id": "ba47a627-7bb8-4918-89b2-6a72af464765",53 * "lineItems": [],54 * "buyerInfo": {55 * "visitorId": "4c7ce95c-9fb3-417d-9f02-b41e82b841f7"56 * },57 * "currency": "EUR",58 * "conversionCurrency": "EUR",59 * "buyerLanguage": "en",60 * "siteLanguage": "en",61 * "taxIncludedInPrices": false,62 * "weightUnit": "KG",63 * "subtotal": {64 * "amount": "0",65 * "convertedAmount": "0",66 * "formattedAmount": "€0.00",67 * "formattedConvertedAmount": "€0.00"68 * },69 * "appliedDiscounts": [],70 * "inSync": true,71 * "_createdDate": "2022-05-15T11:31:30.484Z",72 * "_updatedDate": "2022-06-16T09:18:32.388Z"73 * }74 *75 */