updateCheckout( )
Updates a checkout.
Description
The updateCheckout()
function returns a Promise that resolves to the updated checkout when the specified properties are updated.
Notes:
- If nothing is passed in the request, the call will fail.
- The
checkout.buyerInfo.email
may not be removed once it is set.
Syntax
function updateCheckout(_id: string, checkout: UpdateCheckout, options: UpdateCheckoutOptions): Promise<Checkout>
updateCheckout Parameters
NAME
TYPE
DESCRIPTION
Checkout ID.
Checkout update options.
Returns
Updated checkout.
Return Type:
NAME
TYPE
DESCRIPTION
Date and time the checkout was created.
Checkout ID.
Date and time the checkout was updated.
Additional Fees.
Applied discounts.
Billing information.
Buyer information.
Language for communication with the buyer. Defaults to the site language. For a site that supports multiple languages, this is the language the buyer selected.
Errors when calculating totals.
Cart ID that this checkout was created from. Empty if this checkout wasn't created from a cart.
Sales channel that created the checkout. Supported values:
"WEB"
,"POS"
,"EBAY"
,"AMAZON"
,"WIX_APP_STORE"
,"WIX_INVOICES"
,"BACKOFFICE_MERCHANT"
,"WISH"
,"OTHER_PLATFORM"
.
Whether an order was successfully created from this checkout. For an order to be successful, it must be successfully paid for (unless the total is 0).
All converted prices are displayed in this currency in three-letter ISO-4217 alphabetic format.
ID of the checkout's initiator.
The currency used when submitting the order.
Custom fields.
Additional settings for customization of the checkout process.
Custom settings can only be defined when creating a checkout.
Custom field data for the checkout object.
Extended fields must be configured in the Wix Dev Center before they can be accessed with API calls.
Applied gift card details.
Note: Gift cards are supported through the Wix UI, though the SPI is not currently available. Learn more about Wix Gift Cards.
Line items.
Max: 300 items
Memberships to apply when creating the order.
Remaining amount for the order to be fully paid.
Minimal amount to pay in order to place the order.
Calculated price summary for the checkout.
Persistent ID that correlates between the various eCommerce elements: cart, checkout, and order.
Shipping information.
Site language in which original values are shown.
Whether tax is included in line item prices.
Tax summary.
List of validation violations raised by the Validations Custom Extension SPI.
Weight measurement unit - defaults to site's weight unit. Supported values:
"KG"
"LB"
Was this helpful?
Updates the buyerNote
and adds a coupon to the checkout
1/**************************************2 * Backend code - my-backend-file.jsw *3 *************************************/45import { checkout } from 'wix-ecom-backend';67export async function myUpdateCheckoutFunction(_id, checkoutInfo, options) {8 try {9 const updatedCheckout = await checkout.updateCheckout(_id, checkoutInfo, options);10 console.log('Success! Updated checkout: ', updatedCheckout);11 return updatedCheckout;12 } catch (error) {13 console.error(error);14 // Handle the error15 }16}1718/*************19 * Page code *20 ************/2122import { myUpdateCheckoutFunction } from 'backend/my-backend-file';2324// Sample checkoutId:25const _id = "21fe558e-21a0-4cff-a49b-a4ccb0f7414f";2627const checkoutInfo = {28 // New value for buyerNote29 "buyerNote": "Please gift wrap this order. Thanks!"30}3132const options = {33 // Coupon code to be applied to the checkout34 "couponCode": "SUMMERSALE10"35}3637myUpdateCheckoutFunction(_id, checkoutInfo, options)38 .then((updatedCheckout) => {39 const updatedBuyerNote = updatedCheckout.buyerNote;40 // appliedCoupon boolean resolves to true if coupon object exists41 const appliedCoupon = !!updatedCheckout.appliedDiscounts[0].coupon4243 console.log('Success! Updated checkout:', updatedCheckout);44 return updatedCheckout;45 })46 .catch((error) => {47 console.error(error);48 // Handle the error49 });5051/* Promise resolves to:52 * {53 * "_id": "21fe558e-21a0-4cff-a49b-a4ccb0f7414f",54 * "lineItems": [55 * {56 * "_id": "00000000-0000-0000-0000-000000000001",57 * "quantity": 3,58 * "catalogReference": {59 * "catalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a",60 * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e"61 * },62 * "productName": {63 * "original": "Shirt",64 * "translated": "Shirt"65 * },66 * "url": "https://giftsstore.wixsite.com/greatest-gifts/product-page/shirt",67 * "price": {68 * "amount": "10",69 * "convertedAmount": "10",70 * "formattedAmount": "€10.00",71 * "formattedConvertedAmount": "€10.00"72 * },73 * "lineItemPrice": {74 * "amount": "30",75 * "convertedAmount": "30",76 * "formattedAmount": "€30.00",77 * "formattedConvertedAmount": "€30.00"78 * },79 * "fullPrice": {80 * "amount": "10",81 * "convertedAmount": "10",82 * "formattedAmount": "€10.00",83 * "formattedConvertedAmount": "€10.00"84 * },85 * "priceBeforeDiscounts": {86 * "amount": "10",87 * "convertedAmount": "10",88 * "formattedAmount": "€10.00",89 * "formattedConvertedAmount": "€10.00"90 * },91 * "totalPriceAfterTax": {92 * "amount": "30",93 * "convertedAmount": "30",94 * "formattedAmount": "€30.00",95 * "formattedConvertedAmount": "€30.00"96 * },97 * "totalPriceBeforeTax": {98 * "amount": "30",99 * "convertedAmount": "30",100 * "formattedAmount": "€30.00",101 * "formattedConvertedAmount": "€30.00"102 * },103 * "taxDetails": {104 * "taxableAmount": {105 * "amount": "30",106 * "convertedAmount": "30",107 * "formattedAmount": "€30.00",108 * "formattedConvertedAmount": "€30.00"109 * },110 * "taxRate": "0",111 * "totalTax": {112 * "amount": "0",113 * "convertedAmount": "0",114 * "formattedAmount": "€0.00",115 * "formattedConvertedAmount": "€0.00"116 * },117 * "rateBreakdown": []118 * },119 * "discount": {120 * "amount": "0",121 * "convertedAmount": "0",122 * "formattedAmount": "€0.00",123 * "formattedConvertedAmount": "€0.00"124 * },125 * "descriptionLines": [],126 * "media": "wix:image://v1/3c76e2_c5331f937348492a97df87b0a3b34ea4~mv2.jpg#originWidth=1000&originHeight=1000",127 * "availability": {128 * "status": "AVAILABLE"129 * },130 * "physicalProperties": {131 * "sku": "364115376135191",132 * "shippable": true133 * },134 * "couponScopes": [135 * {136 * "namespace": "stores",137 * "group": {138 * "name": "collection",139 * "entityId": "00000000-000000-000000-000000000001"140 * }141 * },142 * {143 * "namespace": "stores",144 * "group": {145 * "name": "product",146 * "entityId": "c8539b66-7a44-fe18-affc-afec4be8562a"147 * }148 * }149 * ],150 * "itemType": {151 * "preset": "PHYSICAL"152 * },153 * "paymentOption": "FULL_PAYMENT_ONLINE",154 * "rootCatalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a"155 * }156 * ],157 * "shippingInfo": {158 * "carrierServiceOptions": []159 * },160 * "buyerNote": "Please gift wrap this order. Thanks!",161 * "buyerInfo": {162 * "contactId": "a4bc8d90-a91b-467f-a775-77d65dd0442e",163 * "email": "johnnydoe@example.com",164 * "memberId": "ea3d74df-b7dc-4ca1-a7c9-c416b9017a86"165 * },166 * "conversionCurrency": "EUR",167 * "priceSummary": {168 * "subtotal": {169 * "amount": "30",170 * "convertedAmount": "30",171 * "formattedAmount": "€30.00",172 * "formattedConvertedAmount": "€30.00"173 * },174 * "shipping": {175 * "amount": "0",176 * "convertedAmount": "0",177 * "formattedAmount": "€0.00",178 * "formattedConvertedAmount": "€0.00"179 * },180 * "tax": {181 * "amount": "0",182 * "convertedAmount": "0",183 * "formattedAmount": "€0.00",184 * "formattedConvertedAmount": "€0.00"185 * },186 * "discount": {187 * "amount": "0",188 * "convertedAmount": "0",189 * "formattedAmount": "€0.00",190 * "formattedConvertedAmount": "€0.00"191 * },192 * "total": {193 * "amount": "30",194 * "convertedAmount": "30",195 * "formattedAmount": "€30.00",196 * "formattedConvertedAmount": "€30.00"197 * },198 * "additionalFees": {199 * "amount": "0",200 * "convertedAmount": "0",201 * "formattedAmount": "€0.00",202 * "formattedConvertedAmount": "€0.00"203 * }204 * },205 * "calculationErrors": {206 * "orderValidationErrors": []207 * },208 * "appliedDiscounts": [209 * {210 * "discountType": "GLOBAL",211 * "lineItemIds": [],212 * "coupon": {213 * "_id": "fbb94b06-7447-4161-9c48-59bfcdc39e77",214 * "code": "SUMMERSALE10",215 * "amount": {216 * "amount": "10.0",217 * "convertedAmount": "10.0",218 * "formattedAmount": "€10.00",219 * "formattedConvertedAmount": "€10.00"220 * },221 * "name": "SUMMERSALE10",222 * "couponType": "MoneyOff"223 * }224 * }225 * ],226 * "customFields": [],227 * "weightUnit": "KG",228 * "currency": "EUR",229 * "channelType": "WEB",230 * "siteLanguage": "en",231 * "buyerLanguage": "en",232 * "completed": false,233 * "taxIncludedInPrice": false,234 * "createdBy": {235 * "memberId": "ea3d74df-b7dc-4ca1-a7c9-c416b9017a86"236 * },237 * "_createdDate": "2023-02-22T15:49:04.627Z",238 * "_updatedDate": "2023-02-22T16:30:58.947Z",239 * "payNow": {240 * "subtotal": {241 * "amount": "30",242 * "convertedAmount": "30",243 * "formattedAmount": "€30.00",244 * "formattedConvertedAmount": "€30.00"245 * },246 * "shipping": {247 * "amount": "0",248 * "convertedAmount": "0",249 * "formattedAmount": "€0.00",250 * "formattedConvertedAmount": "€0.00"251 * },252 * "tax": {253 * "amount": "0",254 * "convertedAmount": "0",255 * "formattedAmount": "€0.00",256 * "formattedConvertedAmount": "€0.00"257 * },258 * "discount": {259 * "amount": "0",260 * "convertedAmount": "0",261 * "formattedAmount": "€0.00",262 * "formattedConvertedAmount": "€0.00"263 * },264 * "total": {265 * "amount": "30",266 * "convertedAmount": "30",267 * "formattedAmount": "€30.00",268 * "formattedConvertedAmount": "€30.00"269 * },270 * "additionalFees": {271 * "amount": "0",272 * "convertedAmount": "0",273 * "formattedAmount": "€0.00",274 * "formattedConvertedAmount": "€0.00"275 * }276 * },277 * "payLater": {278 * "subtotal": {279 * "amount": "0",280 * "convertedAmount": "0",281 * "formattedAmount": "€0.00",282 * "formattedConvertedAmount": "€0.00"283 * },284 * "shipping": {285 * "amount": "0",286 * "convertedAmount": "0",287 * "formattedAmount": "€0.00",288 * "formattedConvertedAmount": "€0.00"289 * },290 * "tax": {291 * "amount": "0",292 * "convertedAmount": "0",293 * "formattedAmount": "€0.00",294 * "formattedConvertedAmount": "€0.00"295 * },296 * "discount": {297 * "amount": "0",298 * "convertedAmount": "0",299 * "formattedAmount": "€0.00",300 * "formattedConvertedAmount": "€0.00"301 * },302 * "total": {303 * "amount": "0",304 * "convertedAmount": "0",305 * "formattedAmount": "€0.00",306 * "formattedConvertedAmount": "€0.00"307 * },308 * "additionalFees": {309 * "amount": "0",310 * "convertedAmount": "0",311 * "formattedAmount": "€0.00",312 * "formattedConvertedAmount": "€0.00"313 * }314 * },315 * "membershipOptions": {316 * "eligibleMemberships": [],317 * "invalidMemberships": [],318 * "selectedMemberships": {319 * "memberships": []320 * }321 * },322 * "additionalFees": [],323 * "payNowTotalAfterGiftCard": {324 * "amount": "30",325 * "convertedAmount": "30",326 * "formattedAmount": "€30.00",327 * "formattedConvertedAmount": "€30.00"328 * }329 * }330 */
Updates the buyerNote
and adds a coupon to the checkout
1/**************************************2 * Backend code - my-backend-file.web.js *3 *************************************/45import { Permissions, webMethod } from 'wix-web-module';6import { checkout } from 'wix-ecom-backend';78export const myUpdateCheckoutFunction = webMethod(Permissions.Anyone, async (_id, checkoutInfo, options) => {9 try {10 const updatedCheckout = await checkout.updateCheckout(_id, checkoutInfo, options);11 console.log('Success! Updated checkout: ', updatedCheckout);12 return updatedCheckout;13 } catch (error) {14 console.error(error);15 // Handle the error16 }17});1819/*************20 * Page code *21 ************/2223import { myUpdateCheckoutFunction } from 'backend/my-backend-file.web';2425// Sample checkoutId:26const _id = "21fe558e-21a0-4cff-a49b-a4ccb0f7414f";2728const checkoutInfo = {29 // New value for buyerNote30 "buyerNote": "Please gift wrap this order. Thanks!"31}3233const options = {34 // Coupon code to be applied to the checkout35 "couponCode": "SUMMERSALE10"36}3738myUpdateCheckoutFunction(_id, checkoutInfo, options)39 .then((updatedCheckout) => {40 const updatedBuyerNote = updatedCheckout.buyerNote;41 // appliedCoupon boolean resolves to true if coupon object exists42 const appliedCoupon = !!updatedCheckout.appliedDiscounts[0].coupon4344 console.log('Success! Updated checkout:', updatedCheckout);45 return updatedCheckout;46 })47 .catch((error) => {48 console.error(error);49 // Handle the error50 });5152/* Promise resolves to:53 * {54 * "_id": "21fe558e-21a0-4cff-a49b-a4ccb0f7414f",55 * "lineItems": [56 * {57 * "_id": "00000000-0000-0000-0000-000000000001",58 * "quantity": 3,59 * "catalogReference": {60 * "catalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a",61 * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e"62 * },63 * "productName": {64 * "original": "Shirt",65 * "translated": "Shirt"66 * },67 * "url": "https://giftsstore.wixsite.com/greatest-gifts/product-page/shirt",68 * "price": {69 * "amount": "10",70 * "convertedAmount": "10",71 * "formattedAmount": "€10.00",72 * "formattedConvertedAmount": "€10.00"73 * },74 * "lineItemPrice": {75 * "amount": "30",76 * "convertedAmount": "30",77 * "formattedAmount": "€30.00",78 * "formattedConvertedAmount": "€30.00"79 * },80 * "fullPrice": {81 * "amount": "10",82 * "convertedAmount": "10",83 * "formattedAmount": "€10.00",84 * "formattedConvertedAmount": "€10.00"85 * },86 * "priceBeforeDiscounts": {87 * "amount": "10",88 * "convertedAmount": "10",89 * "formattedAmount": "€10.00",90 * "formattedConvertedAmount": "€10.00"91 * },92 * "totalPriceAfterTax": {93 * "amount": "30",94 * "convertedAmount": "30",95 * "formattedAmount": "€30.00",96 * "formattedConvertedAmount": "€30.00"97 * },98 * "totalPriceBeforeTax": {99 * "amount": "30",100 * "convertedAmount": "30",101 * "formattedAmount": "€30.00",102 * "formattedConvertedAmount": "€30.00"103 * },104 * "taxDetails": {105 * "taxableAmount": {106 * "amount": "30",107 * "convertedAmount": "30",108 * "formattedAmount": "€30.00",109 * "formattedConvertedAmount": "€30.00"110 * },111 * "taxRate": "0",112 * "totalTax": {113 * "amount": "0",114 * "convertedAmount": "0",115 * "formattedAmount": "€0.00",116 * "formattedConvertedAmount": "€0.00"117 * },118 * "rateBreakdown": []119 * },120 * "discount": {121 * "amount": "0",122 * "convertedAmount": "0",123 * "formattedAmount": "€0.00",124 * "formattedConvertedAmount": "€0.00"125 * },126 * "descriptionLines": [],127 * "media": "wix:image://v1/3c76e2_c5331f937348492a97df87b0a3b34ea4~mv2.jpg#originWidth=1000&originHeight=1000",128 * "availability": {129 * "status": "AVAILABLE"130 * },131 * "physicalProperties": {132 * "sku": "364115376135191",133 * "shippable": true134 * },135 * "couponScopes": [136 * {137 * "namespace": "stores",138 * "group": {139 * "name": "collection",140 * "entityId": "00000000-000000-000000-000000000001"141 * }142 * },143 * {144 * "namespace": "stores",145 * "group": {146 * "name": "product",147 * "entityId": "c8539b66-7a44-fe18-affc-afec4be8562a"148 * }149 * }150 * ],151 * "itemType": {152 * "preset": "PHYSICAL"153 * },154 * "paymentOption": "FULL_PAYMENT_ONLINE",155 * "rootCatalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a"156 * }157 * ],158 * "shippingInfo": {159 * "carrierServiceOptions": []160 * },161 * "buyerNote": "Please gift wrap this order. Thanks!",162 * "buyerInfo": {163 * "contactId": "a4bc8d90-a91b-467f-a775-77d65dd0442e",164 * "email": "johnnydoe@example.com",165 * "memberId": "ea3d74df-b7dc-4ca1-a7c9-c416b9017a86"166 * },167 * "conversionCurrency": "EUR",168 * "priceSummary": {169 * "subtotal": {170 * "amount": "30",171 * "convertedAmount": "30",172 * "formattedAmount": "€30.00",173 * "formattedConvertedAmount": "€30.00"174 * },175 * "shipping": {176 * "amount": "0",177 * "convertedAmount": "0",178 * "formattedAmount": "€0.00",179 * "formattedConvertedAmount": "€0.00"180 * },181 * "tax": {182 * "amount": "0",183 * "convertedAmount": "0",184 * "formattedAmount": "€0.00",185 * "formattedConvertedAmount": "€0.00"186 * },187 * "discount": {188 * "amount": "0",189 * "convertedAmount": "0",190 * "formattedAmount": "€0.00",191 * "formattedConvertedAmount": "€0.00"192 * },193 * "total": {194 * "amount": "30",195 * "convertedAmount": "30",196 * "formattedAmount": "€30.00",197 * "formattedConvertedAmount": "€30.00"198 * },199 * "additionalFees": {200 * "amount": "0",201 * "convertedAmount": "0",202 * "formattedAmount": "€0.00",203 * "formattedConvertedAmount": "€0.00"204 * }205 * },206 * "calculationErrors": {207 * "orderValidationErrors": []208 * },209 * "appliedDiscounts": [210 * {211 * "discountType": "GLOBAL",212 * "lineItemIds": [],213 * "coupon": {214 * "_id": "fbb94b06-7447-4161-9c48-59bfcdc39e77",215 * "code": "SUMMERSALE10",216 * "amount": {217 * "amount": "10.0",218 * "convertedAmount": "10.0",219 * "formattedAmount": "€10.00",220 * "formattedConvertedAmount": "€10.00"221 * },222 * "name": "SUMMERSALE10",223 * "couponType": "MoneyOff"224 * }225 * }226 * ],227 * "customFields": [],228 * "weightUnit": "KG",229 * "currency": "EUR",230 * "channelType": "WEB",231 * "siteLanguage": "en",232 * "buyerLanguage": "en",233 * "completed": false,234 * "taxIncludedInPrice": false,235 * "createdBy": {236 * "memberId": "ea3d74df-b7dc-4ca1-a7c9-c416b9017a86"237 * },238 * "_createdDate": "2023-02-22T15:49:04.627Z",239 * "_updatedDate": "2023-02-22T16:30:58.947Z",240 * "payNow": {241 * "subtotal": {242 * "amount": "30",243 * "convertedAmount": "30",244 * "formattedAmount": "€30.00",245 * "formattedConvertedAmount": "€30.00"246 * },247 * "shipping": {248 * "amount": "0",249 * "convertedAmount": "0",250 * "formattedAmount": "€0.00",251 * "formattedConvertedAmount": "€0.00"252 * },253 * "tax": {254 * "amount": "0",255 * "convertedAmount": "0",256 * "formattedAmount": "€0.00",257 * "formattedConvertedAmount": "€0.00"258 * },259 * "discount": {260 * "amount": "0",261 * "convertedAmount": "0",262 * "formattedAmount": "€0.00",263 * "formattedConvertedAmount": "€0.00"264 * },265 * "total": {266 * "amount": "30",267 * "convertedAmount": "30",268 * "formattedAmount": "€30.00",269 * "formattedConvertedAmount": "€30.00"270 * },271 * "additionalFees": {272 * "amount": "0",273 * "convertedAmount": "0",274 * "formattedAmount": "€0.00",275 * "formattedConvertedAmount": "€0.00"276 * }277 * },278 * "payLater": {279 * "subtotal": {280 * "amount": "0",281 * "convertedAmount": "0",282 * "formattedAmount": "€0.00",283 * "formattedConvertedAmount": "€0.00"284 * },285 * "shipping": {286 * "amount": "0",287 * "convertedAmount": "0",288 * "formattedAmount": "€0.00",289 * "formattedConvertedAmount": "€0.00"290 * },291 * "tax": {292 * "amount": "0",293 * "convertedAmount": "0",294 * "formattedAmount": "€0.00",295 * "formattedConvertedAmount": "€0.00"296 * },297 * "discount": {298 * "amount": "0",299 * "convertedAmount": "0",300 * "formattedAmount": "€0.00",301 * "formattedConvertedAmount": "€0.00"302 * },303 * "total": {304 * "amount": "0",305 * "convertedAmount": "0",306 * "formattedAmount": "€0.00",307 * "formattedConvertedAmount": "€0.00"308 * },309 * "additionalFees": {310 * "amount": "0",311 * "convertedAmount": "0",312 * "formattedAmount": "€0.00",313 * "formattedConvertedAmount": "€0.00"314 * }315 * },316 * "membershipOptions": {317 * "eligibleMemberships": [],318 * "invalidMemberships": [],319 * "selectedMemberships": {320 * "memberships": []321 * }322 * },323 * "additionalFees": [],324 * "payNowTotalAfterGiftCard": {325 * "amount": "30",326 * "convertedAmount": "30",327 * "formattedAmount": "€30.00",328 * "formattedConvertedAmount": "€30.00"329 * }330 * }331 */