Search...
removeLineItems( )
Removes line items from the specified checkout.
Description
The removeLineItems()
function returns a Promise that resolves to the updated checkout when the line items are removed from the specified checkout.
Syntax
function removeLineItems(_id: string, lineItemIds: Array<string>): Promise<RemoveLineItemsResponse>
removeLineItems Parameters
NAME
TYPE
DESCRIPTION
_id
string
ID of the checkout to remove line items from.
lineItemIds
Array<
string
>IDs of the line items to be removed.
To find the IDs of the checkout line items you'd like to remove, pass the checkout._id
to getCheckout() and look for the IDs under lineItems
and/or customLineItems
.
Returns
Return Type:
Promise<
RemoveLineItemsResponse
>NAME
TYPE
DESCRIPTION
checkout
Checkout
Updated checkout after removal of line items.
Was this helpful?
Remove 2 line items from a checkout
Copy Code
1/**************************************2 * Backend code - my-backend-file.jsw *3 **************************************/45import { checkout } from 'wix-ecom-backend';67export async function myRemoveLineItemsFunction(checkoutId, lineItemIds) {8 try {9 const updatedCheckout = await checkout.removeLineItems(checkoutId, lineItemIds);10 console.log('Success! Line items removed from checkout:', updatedCheckout);11 return updatedCheckout;12 } catch (error) {13 console.error(error);14 // Handle the error15 }16}1718/*************19 * Page code *20 ************/2122import { myRemoveLineItemsFunction } from 'backend/my-backend-file';2324// Sample checkoutId:25const checkoutId = '23a7b29a-3c14-4ef1-9353-f4b714b13217';26// Sample line item IDs27const lineItemIds = ["00000000-0000-0000-0000-000000000002", "00000000-0000-0000-0000-000000000003"]2829myRemoveLineItemsFunction(checkoutId, lineItemIds)30 .then((updatedCheckout) => {31 const checkoutId = updatedCheckout._id;32 const numOfLineItems = updatedCheckout.lineItems.length;3334 console.log('Success! Line items removed from checkout:', updatedCheckout);35 return updatedCheckout;36 })37 .catch((error) => {38 console.error(error);39 // Handle the error40 });4142/* Promise resolves to:43 *44 *45 * {46 * "_id": "23a7b29a-3c14-4ef1-9353-f4b714b13217",47 * "lineItems": [48 * {49 * "_id": "00000000-0000-0000-0000-000000000001",50 * "quantity": 3,51 * "catalogReference": {52 * "catalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a",53 * "appId": "1380b703-ce81-ff05-f115-39571d94dfcd"54 * },55 * "productName": {56 * "original": "Shirt",57 * "translated": "Shirt"58 * },59 * "url": "https://example.wixsite.com",60 * "price": {61 * "amount": "10",62 * "convertedAmount": "10",63 * "formattedAmount": "$10.00",64 * "formattedConvertedAmount": "$10.00"65 * },66 * "lineItemPrice": {67 * "amount": "30",68 * "convertedAmount": "30",69 * "formattedAmount": "$30.00",70 * "formattedConvertedAmount": "$30.00"71 * },72 * "fullPrice": {73 * "amount": "10",74 * "convertedAmount": "10",75 * "formattedAmount": "$10.00",76 * "formattedConvertedAmount": "$10.00"77 * },78 * "priceBeforeDiscounts": {79 * "amount": "10",80 * "convertedAmount": "10",81 * "formattedAmount": "$10.00",82 * "formattedConvertedAmount": "$10.00"83 * },84 * "totalPriceAfterTax": {85 * "amount": "20",86 * "convertedAmount": "20",87 * "formattedAmount": "$20.00",88 * "formattedConvertedAmount": "$20.00"89 * },90 * "totalPriceBeforeTax": {91 * "amount": "20",92 * "convertedAmount": "20",93 * "formattedAmount": "$20.00",94 * "formattedConvertedAmount": "$20.00"95 * },96 * "taxDetails": {97 * "taxableAmount": {98 * "amount": "20",99 * "convertedAmount": "20",100 * "formattedAmount": "$20.00",101 * "formattedConvertedAmount": "$20.00"102 * },103 * "taxRate": "0",104 * "totalTax": {105 * "amount": "0",106 * "convertedAmount": "0",107 * "formattedAmount": "$0.00",108 * "formattedConvertedAmount": "$0.00"109 * },110 * "rateBreakdown": []111 * },112 * "discount": {113 * "amount": "10",114 * "convertedAmount": "10",115 * "formattedAmount": "$10.00",116 * "formattedConvertedAmount": "$10.00"117 * },118 * "descriptionLines": [],119 * "media": "wix:image://v1/3c76e2_c5331f937348492a97df87b0a3b34ea4~mv2.jpg#originWidth=1000&originHeight=1000",120 * "availability": {121 * "status": "AVAILABLE"122 * },123 * "physicalProperties": {124 * "sku": "364115376135191",125 * "shippable": true126 * },127 * "couponScopes": [128 * {129 * "namespace": "stores",130 * "group": {131 * "name": "collection",132 * "entityId": "00000000-000000-000000-000000000001"133 * }134 * },135 * {136 * "namespace": "stores",137 * "group": {138 * "name": "product",139 * "entityId": "c8539b66-7a44-fe18-affc-afec4be8562a"140 * }141 * }142 * ],143 * "itemType": {144 * "preset": "PHYSICAL"145 * },146 * "paymentOption": "FULL_PAYMENT_ONLINE",147 * "rootCatalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a"148 * }149 * ],150 * "billingInfo": {151 * "address": {152 * "addressLine1": "235 West 23rd Street",153 * "addressLine2": "3rd floor",154 * "city": "New York",155 * "subdivision": "US-NY",156 * "country": "US",157 * "postalCode": "10011"158 * },159 * "contactDetails": {160 * "firstName": "Jane",161 * "lastName": "Doe",162 * "phone": "+1234567890"163 * }164 * },165 * "shippingInfo": {166 * "shippingDestination": {167 * "address": {168 * "addressLine1": "235 West 23rd Street",169 * "addressLine2": "3rd floor",170 * "city": "New York",171 * "subdivision": "US-NY",172 * "country": "US",173 * "postalCode": "10011"174 * },175 * "contactDetails": {176 * "firstName": "Jane",177 * "lastName": "Doe",178 * "phone": "+1234567890"179 * }180 * },181 * "selectedCarrierServiceOption": {182 * "code": "ed5bbce2-9533-dff4-7db0-13702fd139c5",183 * "title": "Standard US Shipping",184 * "logistics": {185 * "deliveryTime": ""186 * },187 * "cost": {188 * "totalPriceAfterTax": {189 * "amount": "10",190 * "convertedAmount": "10",191 * "formattedAmount": "$10.00",192 * "formattedConvertedAmount": "$10.00"193 * },194 * "totalPriceBeforeTax": {195 * "amount": "10",196 * "convertedAmount": "10",197 * "formattedAmount": "$10.00",198 * "formattedConvertedAmount": "$10.00"199 * },200 * "taxDetails": {201 * "taxRate": "0",202 * "totalTax": {203 * "amount": "0",204 * "convertedAmount": "0",205 * "formattedAmount": "$0.00",206 * "formattedConvertedAmount": "$0.00"207 * },208 * "rateBreakdown": []209 * },210 * "price": {211 * "amount": "10",212 * "convertedAmount": "10",213 * "formattedAmount": "$10.00",214 * "formattedConvertedAmount": "$10.00"215 * }216 * },217 * "requestedShippingOption": true,218 * "otherCharges": [],219 * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc"220 * },221 * "region": {222 * "_id": "009fbe5d-89d3-7825-cbbf-1aab4d908b73",223 * "name": "USA shipping"224 * },225 * "carrierServiceOptions": [226 * {227 * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc",228 * "shippingOptions": [229 * {230 * "code": "ed5bbce2-9533-dff4-7db0-13702fd139c5",231 * "title": "Standard US Shipping",232 * "logistics": {233 * "deliveryTime": ""234 * },235 * "cost": {236 * "price": {237 * "amount": "10",238 * "convertedAmount": "10",239 * "formattedAmount": "$10.00",240 * "formattedConvertedAmount": "$10.00"241 * },242 * "otherCharges": []243 * }244 * }245 * ]246 * }247 * ]248 * },249 * "buyerNote": "Please wrap it up as a present",250 * "buyerInfo": {251 * "contactId": "f7dc17a6-825a-466e-a78e-c4abea0217db",252 * "email": "Janedoe@example.com",253 * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873"254 * },255 * "conversionCurrency": "USD",256 * "priceSummary": {257 * "subtotal": {258 * "amount": "30",259 * "convertedAmount": "30",260 * "formattedAmount": "$30.00",261 * "formattedConvertedAmount": "$30.00"262 * },263 * "shipping": {264 * "amount": "10",265 * "convertedAmount": "10",266 * "formattedAmount": "$10.00",267 * "formattedConvertedAmount": "$10.00"268 * },269 * "tax": {270 * "amount": "0",271 * "convertedAmount": "0",272 * "formattedAmount": "$0.00",273 * "formattedConvertedAmount": "$0.00"274 * },275 * "discount": {276 * "amount": "10",277 * "convertedAmount": "10",278 * "formattedAmount": "$10.00",279 * "formattedConvertedAmount": "$10.00"280 * },281 * "total": {282 * "amount": "30",283 * "convertedAmount": "30",284 * "formattedAmount": "$30.00",285 * "formattedConvertedAmount": "$30.00"286 * },287 * "additionalFees": {288 * "amount": "0",289 * "convertedAmount": "0",290 * "formattedAmount": "$0.00",291 * "formattedConvertedAmount": "$0.00"292 * }293 * },294 * "calculationErrors": {295 * "orderValidationErrors": []296 * },297 * "appliedDiscounts": [298 * {299 * "discountType": "GLOBAL",300 * "lineItemIds": [],301 * "coupon": {302 * "_id": "fbb94b06-7447-4161-9c48-59bfcdc39e77",303 * "code": "SUMMERSALE10",304 * "amount": {305 * "amount": "10",306 * "convertedAmount": "10",307 * "formattedAmount": "$10.00",308 * "formattedConvertedAmount": "$10.00"309 * },310 * "name": "SUMMERSALE10",311 * "couponType": "MoneyOff"312 * }313 * }314 * ],315 * "customFields": [316 * {317 * "value": "12345",318 * "title": "Tax ID",319 * "translatedTitle": "Tax ID"320 * }321 * ],322 * "weightUnit": "KG",323 * "currency": "USD",324 * "channelType": "WEB",325 * "siteLanguage": "en",326 * "buyerLanguage": "en",327 * "completed": false,328 * "taxIncludedInPrice": false,329 * "createdBy": {330 * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873"331 * },332 * "_createdDate": "2022-10-26T10:55:56.759Z",333 * "_updatedDate": "2022-10-26T10:56:59.653Z",334 * "payNow": {335 * "subtotal": {336 * "amount": "30",337 * "convertedAmount": "30",338 * "formattedAmount": "$30.00",339 * "formattedConvertedAmount": "$30.00"340 * },341 * "shipping": {342 * "amount": "10",343 * "convertedAmount": "10",344 * "formattedAmount": "$10.00",345 * "formattedConvertedAmount": "$10.00"346 * },347 * "tax": {348 * "amount": "0",349 * "convertedAmount": "0",350 * "formattedAmount": "$0.00",351 * "formattedConvertedAmount": "$0.00"352 * },353 * "discount": {354 * "amount": "10",355 * "convertedAmount": "10",356 * "formattedAmount": "$10.00",357 * "formattedConvertedAmount": "$10.00"358 * },359 * "total": {360 * "amount": "30",361 * "convertedAmount": "30",362 * "formattedAmount": "$30.00",363 * "formattedConvertedAmount": "$30.00"364 * },365 * "additionalFees": {366 * "amount": "0",367 * "convertedAmount": "0",368 * "formattedAmount": "$0.00",369 * "formattedConvertedAmount": "$0.00"370 * }371 * },372 * "payLater": {373 * "subtotal": {374 * "amount": "0",375 * "convertedAmount": "0",376 * "formattedAmount": "$0.00",377 * "formattedConvertedAmount": "$0.00"378 * },379 * "shipping": {380 * "amount": "0",381 * "convertedAmount": "0",382 * "formattedAmount": "$0.00",383 * "formattedConvertedAmount": "$0.00"384 * },385 * "tax": {386 * "amount": "0",387 * "convertedAmount": "0",388 * "formattedAmount": "$0.00",389 * "formattedConvertedAmount": "$0.00"390 * },391 * "discount": {392 * "amount": "0",393 * "convertedAmount": "0",394 * "formattedAmount": "$0.00",395 * "formattedConvertedAmount": "$0.00"396 * },397 * "total": {398 * "amount": "0",399 * "convertedAmount": "0",400 * "formattedAmount": "$0.00",401 * "formattedConvertedAmount": "$0.00"402 * },403 * "additionalFees": {404 * "amount": "0",405 * "convertedAmount": "0",406 * "formattedAmount": "$0.00",407 * "formattedConvertedAmount": "$0.00"408 * }409 * },410 * "membershipOptions": {411 * "eligibleMemberships": [],412 * "invalidMemberships": [],413 * "selectedMemberships": {414 * "memberships": []415 * }416 * },417 * "additionalFees": []418 * }419 *420 */421