Search...
removeGiftCard( )
Removes the gift card from a specified checkout.
Description
The removeGiftCard()
function returns a Promise that resolves to the updated checkout when the gift card is removed from the specified checkout.
Note: A checkout can only hold 1 gift card.
Syntax
function removeGiftCard(_id: string): Promise<RemoveGiftCardResponse>
removeGiftCard Parameters
NAME
TYPE
DESCRIPTION
_id
string
ID of the checkout to remove the gift card from.
Returns
Return Type:
Promise<
RemoveGiftCardResponse
>NAME
TYPE
DESCRIPTION
checkout
Checkout
Updated checkout after removal of gift card.
Was this helpful?
Remove the gift card from a checkout
Copy Code
1/**************************************2 * Backend code - my-backend-file.jsw *3 **************************************/45import { checkout } from 'wix-ecom-backend';67export async function myRemoveGiftCardFunction(checkoutId) {8 try {9 const updatedCheckout = await checkout.removeGiftCard(checkoutId);10 console.log('Success! Removed gift card from checkout:', updatedCheckout);11 return updatedCheckout;12 } catch (error) {13 console.error(error);14 // Handle the error15 }16}1718/*************19 * Page code *20 ************/2122import { myRemoveGiftCardFunction } from 'backend/my-backend-file';2324// Sample checkoutId:25const checkoutId = '84d74a0e-5c3c-4113-8bd2-d264cc60d82a';2627myRemoveGiftCardFunction(checkoutId)28 .then((updatedCheckout) => {29 const checkoutId = updatedCheckout._id;30 const totalPrice = updatedCheckout.priceSummary.total;3132 console.log('Success! Removed gift card from checkout:', updatedCheckout);33 return updatedCheckout;34 })35 .catch((error) => {36 console.error(error);37 // Handle the error38 });3940/* Promise resolves to:41 *42 * {43 * "_id": "84d74a0e-5c3c-4113-8bd2-d264cc60d82a",44 * "lineItems": [45 * {46 * "_id": "00000000-0000-0000-0000-000000000001",47 * "quantity": 1,48 * "catalogReference": {49 * "catalogItemId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09",50 * "appId": "1380b703-ce81-ff05-f115-39571d94dfcd",51 * "options": {52 * "variantId": "132b84e8-aab8-47a1-a1f6-2c47557b64a4"53 * }54 * },55 * "productName": {56 * "original": "Watch",57 * "translated": "Watch"58 * },59 * "url": "https://example.wixsite.com",60 * "price": {61 * "amount": "30",62 * "convertedAmount": "30",63 * "formattedAmount": "$30.00",64 * "formattedConvertedAmount": "$30.00"65 * },66 * "lineItemPrice": {67 * "amount": "30",68 * "convertedAmount": "30",69 * "formattedAmount": "$30.00",70 * "formattedConvertedAmount": "$30.00"71 * },72 * "fullPrice": {73 * "amount": "30",74 * "convertedAmount": "30",75 * "formattedAmount": "$30.00",76 * "formattedConvertedAmount": "$30.00"77 * },78 * "priceBeforeDiscounts": {79 * "amount": "30",80 * "convertedAmount": "30",81 * "formattedAmount": "$30.00",82 * "formattedConvertedAmount": "$30.00"83 * },84 * "totalPriceAfterTax": {85 * "amount": "30",86 * "convertedAmount": "30",87 * "formattedAmount": "$30.00",88 * "formattedConvertedAmount": "$30.00"89 * },90 * "totalPriceBeforeTax": {91 * "amount": "30",92 * "convertedAmount": "30",93 * "formattedAmount": "$30.00",94 * "formattedConvertedAmount": "$30.00"95 * },96 * "taxDetails": {97 * "taxableAmount": {98 * "amount": "30",99 * "convertedAmount": "30",100 * "formattedAmount": "$30.00",101 * "formattedConvertedAmount": "$30.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": "0",114 * "convertedAmount": "0",115 * "formattedAmount": "$0.00",116 * "formattedConvertedAmount": "$0.00"117 * },118 * "descriptionLines": [119 * {120 * "name": {121 * "original": "Size",122 * "translated": "Size"123 * },124 * "plainText": {125 * "original": "Medium",126 * "translated": "Medium"127 * },128 * "lineType": "PLAIN_TEXT",129 * "plainTextValue": {130 * "original": "Medium",131 * "translated": "Medium"132 * }133 * },134 * {135 * "name": {136 * "original": "Color",137 * "translated": "Color"138 * },139 * "colorInfo": {140 * "original": "Grey",141 * "translated": "Grey",142 * "code": "rgb(128, 128, 128)"143 * },144 * "lineType": "COLOR",145 * "color": "Grey"146 * }147 * ],148 * "media": "wix:image://v1/3c76e2_8891bbe3372a428aac976ac59aa0ac74~mv2.jpg#originWidth=1000&originHeight=1000",149 * "availability": {150 * "status": "AVAILABLE"151 * },152 * "physicalProperties": {153 * "sku": "217537123517253",154 * "shippable": true155 * },156 * "couponScopes": [157 * {158 * "namespace": "stores",159 * "group": {160 * "name": "collection",161 * "entityId": "00000000-000000-000000-000000000001"162 * }163 * },164 * {165 * "namespace": "stores",166 * "group": {167 * "name": "product",168 * "entityId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09"169 * }170 * }171 * ],172 * "itemType": {173 * "preset": "PHYSICAL"174 * },175 * "paymentOption": "FULL_PAYMENT_ONLINE",176 * "rootCatalogItemId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09"177 * }178 * ],179 * "billingInfo": {180 * "address": {181 * "addressLine1": "525 5th Avenue",182 * "city": "New York",183 * "subdivision": "US-NY",184 * "country": "US",185 * "postalCode": "10173"186 * },187 * "contactDetails": {188 * "firstName": "Jane",189 * "lastName": "Doe",190 * "phone": "0555555555"191 * }192 * },193 * "shippingInfo": {194 * "shippingDestination": {195 * "address": {196 * "addressLine1": "525 5th Avenue",197 * "city": "New York",198 * "subdivision": "US-NY",199 * "country": "US",200 * "postalCode": "10173"201 * },202 * "contactDetails": {203 * "firstName": "Jane",204 * "lastName": "Doe",205 * "phone": "0555555555"206 * }207 * },208 * "selectedCarrierServiceOption": {209 * "code": "ed5bbce2-9533-dff4-7db0-13702fd139c5",210 * "title": "Standard US Shipping",211 * "logistics": {212 * "deliveryTime": ""213 * },214 * "cost": {215 * "totalPriceAfterTax": {216 * "amount": "10",217 * "convertedAmount": "10",218 * "formattedAmount": "$10.00",219 * "formattedConvertedAmount": "$10.00"220 * },221 * "totalPriceBeforeTax": {222 * "amount": "10",223 * "convertedAmount": "10",224 * "formattedAmount": "$10.00",225 * "formattedConvertedAmount": "$10.00"226 * },227 * "taxDetails": {228 * "taxRate": "0",229 * "totalTax": {230 * "amount": "0",231 * "convertedAmount": "0",232 * "formattedAmount": "$0.00",233 * "formattedConvertedAmount": "$0.00"234 * },235 * "rateBreakdown": []236 * },237 * "price": {238 * "amount": "10",239 * "convertedAmount": "10",240 * "formattedAmount": "$10.00",241 * "formattedConvertedAmount": "$10.00"242 * }243 * },244 * "requestedShippingOption": true,245 * "otherCharges": [],246 * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc"247 * },248 * "region": {249 * "_id": "009fbe5d-89d3-7825-cbbf-1aab4d908b73",250 * "name": "USA shipping"251 * },252 * "carrierServiceOptions": [253 * {254 * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc",255 * "shippingOptions": [256 * {257 * "code": "ed5bbce2-9533-dff4-7db0-13702fd139c5",258 * "title": "Standard US Shipping",259 * "logistics": {260 * "deliveryTime": ""261 * },262 * "cost": {263 * "price": {264 * "amount": "10",265 * "convertedAmount": "10",266 * "formattedAmount": "$10.00",267 * "formattedConvertedAmount": "$10.00"268 * },269 * "otherCharges": []270 * }271 * }272 * ]273 * }274 * ]275 * },276 * "buyerInfo": {277 * "contactId": "24de6f0b-60ce-4faa-9138-2e39f1415615",278 * "email": "janedoe@gmail.com",279 * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873"280 * },281 * "conversionCurrency": "USD",282 * "priceSummary": {283 * "subtotal": {284 * "amount": "30",285 * "convertedAmount": "30",286 * "formattedAmount": "$30.00",287 * "formattedConvertedAmount": "$30.00"288 * },289 * "shipping": {290 * "amount": "10",291 * "convertedAmount": "10",292 * "formattedAmount": "$10.00",293 * "formattedConvertedAmount": "$10.00"294 * },295 * "tax": {296 * "amount": "0",297 * "convertedAmount": "0",298 * "formattedAmount": "$0.00",299 * "formattedConvertedAmount": "$0.00"300 * },301 * "discount": {302 * "amount": "0",303 * "convertedAmount": "0",304 * "formattedAmount": "$0.00",305 * "formattedConvertedAmount": "$0.00"306 * },307 * "total": {308 * "amount": "40",309 * "convertedAmount": "40",310 * "formattedAmount": "$40.00",311 * "formattedConvertedAmount": "$40.00"312 * },313 * "additionalFees": {314 * "amount": "0",315 * "convertedAmount": "0",316 * "formattedAmount": "$0.00",317 * "formattedConvertedAmount": "$0.00"318 * }319 * },320 * "calculationErrors": {321 * "orderValidationErrors": []322 * },323 * "appliedDiscounts": [],324 * "customFields": [],325 * "weightUnit": "KG",326 * "currency": "USD",327 * "channelType": "WEB",328 * "siteLanguage": "en",329 * "buyerLanguage": "en",330 * "completed": false,331 * "taxIncludedInPrice": false,332 * "createdBy": {333 * "visitorId": "4c7ce95c-9fb3-417d-9f02-b41e82b841f7"334 * },335 * "_createdDate": "2022-10-27T08:51:44.099Z",336 * "_updatedDate": "2022-10-27T08:54:53.785Z",337 * "payNow": {338 * "subtotal": {339 * "amount": "30",340 * "convertedAmount": "30",341 * "formattedAmount": "$30.00",342 * "formattedConvertedAmount": "$30.00"343 * },344 * "shipping": {345 * "amount": "10",346 * "convertedAmount": "10",347 * "formattedAmount": "$10.00",348 * "formattedConvertedAmount": "$10.00"349 * },350 * "tax": {351 * "amount": "0",352 * "convertedAmount": "0",353 * "formattedAmount": "$0.00",354 * "formattedConvertedAmount": "$0.00"355 * },356 * "discount": {357 * "amount": "0",358 * "convertedAmount": "0",359 * "formattedAmount": "$0.00",360 * "formattedConvertedAmount": "$0.00"361 * },362 * "total": {363 * "amount": "40",364 * "convertedAmount": "40",365 * "formattedAmount": "$40.00",366 * "formattedConvertedAmount": "$40.00"367 * },368 * "additionalFees": {369 * "amount": "0",370 * "convertedAmount": "0",371 * "formattedAmount": "$0.00",372 * "formattedConvertedAmount": "$0.00"373 * }374 * },375 * "payLater": {376 * "subtotal": {377 * "amount": "0",378 * "convertedAmount": "0",379 * "formattedAmount": "$0.00",380 * "formattedConvertedAmount": "$0.00"381 * },382 * "shipping": {383 * "amount": "0",384 * "convertedAmount": "0",385 * "formattedAmount": "$0.00",386 * "formattedConvertedAmount": "$0.00"387 * },388 * "tax": {389 * "amount": "0",390 * "convertedAmount": "0",391 * "formattedAmount": "$0.00",392 * "formattedConvertedAmount": "$0.00"393 * },394 * "discount": {395 * "amount": "0",396 * "convertedAmount": "0",397 * "formattedAmount": "$0.00",398 * "formattedConvertedAmount": "$0.00"399 * },400 * "total": {401 * "amount": "0",402 * "convertedAmount": "0",403 * "formattedAmount": "$0.00",404 * "formattedConvertedAmount": "$0.00"405 * },406 * "additionalFees": {407 * "amount": "0",408 * "convertedAmount": "0",409 * "formattedAmount": "$0.00",410 * "formattedConvertedAmount": "$0.00"411 * }412 * },413 * "membershipOptions": {414 * "eligibleMemberships": [],415 * "invalidMemberships": [],416 * "selectedMemberships": {417 * "memberships": []418 * }419 * },420 * "additionalFees": [],421 * "cartId": "d7aca608-cbbd-4a22-9813-0459992abd1f"422 * }423 *424 */425