> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - 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: updateCheckout(_id: string, checkout: UpdateCheckout, options: UpdateCheckoutOptions)

# Method package: wixEcomBackend

# Method menu location: wixEcomBackend --> checkout --> updateCheckout

# Method Link: https://dev.wix.com/docs/velo/apis/wix-ecom-backend/checkout/update-checkout.md

# Method Description:

Updates a checkout.


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.



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## Update a checkout

```javascript
/**************************************
 * Backend code - my-backend-file.jsw *
 *************************************/

import { checkout } from 'wix-ecom-backend';

export async function myUpdateCheckoutFunction(_id, checkoutInfo, options) {
  try {
    const updatedCheckout = await checkout.updateCheckout(_id, checkoutInfo, options);
    console.log('Success! Updated checkout: ', updatedCheckout);
    return updatedCheckout;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/*************
 * Page code *
 ************/

import { myUpdateCheckoutFunction } from 'backend/my-backend-file';

// Sample checkoutId:
const _id = "21fe558e-21a0-4cff-a49b-a4ccb0f7414f";

const checkoutInfo = {
  // New value for buyerNote
  "buyerNote": "Please gift wrap this order. Thanks!"
}

const options = {
  // Coupon code to be applied to the checkout
  "couponCode": "SUMMERSALE10"
}

myUpdateCheckoutFunction(_id, checkoutInfo, options)
  .then((updatedCheckout) => {
    const updatedBuyerNote = updatedCheckout.buyerNote;
    // appliedCoupon boolean resolves to true if coupon object exists
    const appliedCoupon = !!updatedCheckout.appliedDiscounts[0].coupon

    console.log('Success! Updated checkout:', updatedCheckout);
    return updatedCheckout;
  })
  .catch((error) => {
    console.error(error);
    // Handle the error
  });

/* Promise resolves to:
 * {
 *   "_id": "21fe558e-21a0-4cff-a49b-a4ccb0f7414f",
 *   "lineItems": [
 *     {
 *       "_id": "00000000-0000-0000-0000-000000000001",
 *       "quantity": 3,
 *       "catalogReference": {
 *         "catalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a",
 *         "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e"
 *       },
 *       "productName": {
 *         "original": "Shirt",
 *         "translated": "Shirt"
 *       },
 *       "url": "https://giftsstore.wixsite.com/greatest-gifts/product-page/shirt",
 *       "price": {
 *         "amount": "10",
 *         "convertedAmount": "10",
 *         "formattedAmount": "€10.00",
 *         "formattedConvertedAmount": "€10.00"
 *       },
 *       "lineItemPrice": {
 *         "amount": "30",
 *         "convertedAmount": "30",
 *         "formattedAmount": "€30.00",
 *         "formattedConvertedAmount": "€30.00"
 *       },
 *       "fullPrice": {
 *         "amount": "10",
 *         "convertedAmount": "10",
 *         "formattedAmount": "€10.00",
 *         "formattedConvertedAmount": "€10.00"
 *       },
 *       "priceBeforeDiscounts": {
 *         "amount": "10",
 *         "convertedAmount": "10",
 *         "formattedAmount": "€10.00",
 *         "formattedConvertedAmount": "€10.00"
 *       },
 *       "totalPriceAfterTax": {
 *         "amount": "30",
 *         "convertedAmount": "30",
 *         "formattedAmount": "€30.00",
 *         "formattedConvertedAmount": "€30.00"
 *       },
 *       "totalPriceBeforeTax": {
 *         "amount": "30",
 *         "convertedAmount": "30",
 *         "formattedAmount": "€30.00",
 *         "formattedConvertedAmount": "€30.00"
 *       },
 *       "taxDetails": {
 *         "taxableAmount": {
 *           "amount": "30",
 *           "convertedAmount": "30",
 *           "formattedAmount": "€30.00",
 *           "formattedConvertedAmount": "€30.00"
 *         },
 *         "taxRate": "0",
 *         "totalTax": {
 *           "amount": "0",
 *           "convertedAmount": "0",
 *           "formattedAmount": "€0.00",
 *           "formattedConvertedAmount": "€0.00"
 *         },
 *         "rateBreakdown": []
 *       },
 *       "discount": {
 *         "amount": "0",
 *         "convertedAmount": "0",
 *         "formattedAmount": "€0.00",
 *         "formattedConvertedAmount": "€0.00"
 *       },
 *       "descriptionLines": [],
 *       "media": "wix:image://v1/3c76e2_c5331f937348492a97df87b0a3b34ea4~mv2.jpg#originWidth=1000&originHeight=1000",
 *       "availability": {
 *         "status": "AVAILABLE"
 *       },
 *       "physicalProperties": {
 *         "sku": "364115376135191",
 *         "shippable": true
 *       },
 *       "couponScopes": [
 *         {
 *           "namespace": "stores",
 *           "group": {
 *             "name": "collection",
 *             "entityId": "00000000-000000-000000-000000000001"
 *           }
 *         },
 *         {
 *           "namespace": "stores",
 *           "group": {
 *             "name": "product",
 *             "entityId": "c8539b66-7a44-fe18-affc-afec4be8562a"
 *           }
 *         }
 *       ],
 *       "itemType": {
 *         "preset": "PHYSICAL"
 *       },
 *       "paymentOption": "FULL_PAYMENT_ONLINE",
 *       "rootCatalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a"
 *     }
 *   ],
 *   "shippingInfo": {
 *     "carrierServiceOptions": []
 *   },
 *   "buyerNote": "Please gift wrap this order. Thanks!",
 *   "buyerInfo": {
 *     "contactId": "a4bc8d90-a91b-467f-a775-77d65dd0442e",
 *     "email": "johnnydoe@example.com",
 *     "memberId": "ea3d74df-b7dc-4ca1-a7c9-c416b9017a86"
 *   },
 *   "conversionCurrency": "EUR",
 *   "priceSummary": {
 *     "subtotal": {
 *       "amount": "30",
 *       "convertedAmount": "30",
 *       "formattedAmount": "€30.00",
 *       "formattedConvertedAmount": "€30.00"
 *     },
 *     "shipping": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "tax": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "discount": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "total": {
 *       "amount": "30",
 *       "convertedAmount": "30",
 *       "formattedAmount": "€30.00",
 *       "formattedConvertedAmount": "€30.00"
 *     },
 *     "additionalFees": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     }
 *   },
 *   "calculationErrors": {
 *     "orderValidationErrors": []
 *   },
 *   "appliedDiscounts": [
 *     {
 *       "discountType": "GLOBAL",
 *       "lineItemIds": [],
 *       "coupon": {
 *         "_id": "fbb94b06-7447-4161-9c48-59bfcdc39e77",
 *         "code": "SUMMERSALE10",
 *         "amount": {
 *           "amount": "10.0",
 *           "convertedAmount": "10.0",
 *           "formattedAmount": "€10.00",
 *           "formattedConvertedAmount": "€10.00"
 *         },
 *         "name": "SUMMERSALE10",
 *         "couponType": "MoneyOff"
 *       }
 *     }
 *   ],
 *   "customFields": [],
 *   "weightUnit": "KG",
 *   "currency": "EUR",
 *   "channelType": "WEB",
 *   "siteLanguage": "en",
 *   "buyerLanguage": "en",
 *   "completed": false,
 *   "taxIncludedInPrice": false,
 *   "createdBy": {
 *     "memberId": "ea3d74df-b7dc-4ca1-a7c9-c416b9017a86"
 *   },
 *   "_createdDate": "2023-02-22T15:49:04.627Z",
 *   "_updatedDate": "2023-02-22T16:30:58.947Z",
 *   "payNow": {
 *     "subtotal": {
 *       "amount": "30",
 *       "convertedAmount": "30",
 *       "formattedAmount": "€30.00",
 *       "formattedConvertedAmount": "€30.00"
 *     },
 *     "shipping": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "tax": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "discount": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "total": {
 *       "amount": "30",
 *       "convertedAmount": "30",
 *       "formattedAmount": "€30.00",
 *       "formattedConvertedAmount": "€30.00"
 *     },
 *     "additionalFees": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     }
 *   },
 *   "payLater": {
 *     "subtotal": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "shipping": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "tax": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "discount": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "total": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "additionalFees": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     }
 *   },
 *   "membershipOptions": {
 *     "eligibleMemberships": [],
 *     "invalidMemberships": [],
 *     "selectedMemberships": {
 *       "memberships": []
 *     }
 *   },
 *   "additionalFees": [],
 *   "payNowTotalAfterGiftCard": {
 *     "amount": "30",
 *     "convertedAmount": "30",
 *     "formattedAmount": "€30.00",
 *     "formattedConvertedAmount": "€30.00"
 *   }
 * } 
 */
```

## Update a checkout (export from backend code)

```javascript
/**************************************
 * Backend code - my-backend-file.web.js *
 *************************************/

import { Permissions, webMethod } from 'wix-web-module';
import { checkout } from 'wix-ecom-backend';

export const myUpdateCheckoutFunction = webMethod(Permissions.Anyone, async (_id, checkoutInfo, options) => {
  try {
    const updatedCheckout = await checkout.updateCheckout(_id, checkoutInfo, options);
    console.log('Success! Updated checkout: ', updatedCheckout);
    return updatedCheckout;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
});

/*************
 * Page code *
 ************/

import { myUpdateCheckoutFunction } from 'backend/my-backend-file.web';

// Sample checkoutId:
const _id = "21fe558e-21a0-4cff-a49b-a4ccb0f7414f";

const checkoutInfo = {
  // New value for buyerNote
  "buyerNote": "Please gift wrap this order. Thanks!"
}

const options = {
  // Coupon code to be applied to the checkout
  "couponCode": "SUMMERSALE10"
}

myUpdateCheckoutFunction(_id, checkoutInfo, options)
  .then((updatedCheckout) => {
    const updatedBuyerNote = updatedCheckout.buyerNote;
    // appliedCoupon boolean resolves to true if coupon object exists
    const appliedCoupon = !!updatedCheckout.appliedDiscounts[0].coupon

    console.log('Success! Updated checkout:', updatedCheckout);
    return updatedCheckout;
  })
  .catch((error) => {
    console.error(error);
    // Handle the error
  });

/* Promise resolves to:
 * {
 *   "_id": "21fe558e-21a0-4cff-a49b-a4ccb0f7414f",
 *   "lineItems": [
 *     {
 *       "_id": "00000000-0000-0000-0000-000000000001",
 *       "quantity": 3,
 *       "catalogReference": {
 *         "catalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a",
 *         "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e"
 *       },
 *       "productName": {
 *         "original": "Shirt",
 *         "translated": "Shirt"
 *       },
 *       "url": "https://giftsstore.wixsite.com/greatest-gifts/product-page/shirt",
 *       "price": {
 *         "amount": "10",
 *         "convertedAmount": "10",
 *         "formattedAmount": "€10.00",
 *         "formattedConvertedAmount": "€10.00"
 *       },
 *       "lineItemPrice": {
 *         "amount": "30",
 *         "convertedAmount": "30",
 *         "formattedAmount": "€30.00",
 *         "formattedConvertedAmount": "€30.00"
 *       },
 *       "fullPrice": {
 *         "amount": "10",
 *         "convertedAmount": "10",
 *         "formattedAmount": "€10.00",
 *         "formattedConvertedAmount": "€10.00"
 *       },
 *       "priceBeforeDiscounts": {
 *         "amount": "10",
 *         "convertedAmount": "10",
 *         "formattedAmount": "€10.00",
 *         "formattedConvertedAmount": "€10.00"
 *       },
 *       "totalPriceAfterTax": {
 *         "amount": "30",
 *         "convertedAmount": "30",
 *         "formattedAmount": "€30.00",
 *         "formattedConvertedAmount": "€30.00"
 *       },
 *       "totalPriceBeforeTax": {
 *         "amount": "30",
 *         "convertedAmount": "30",
 *         "formattedAmount": "€30.00",
 *         "formattedConvertedAmount": "€30.00"
 *       },
 *       "taxDetails": {
 *         "taxableAmount": {
 *           "amount": "30",
 *           "convertedAmount": "30",
 *           "formattedAmount": "€30.00",
 *           "formattedConvertedAmount": "€30.00"
 *         },
 *         "taxRate": "0",
 *         "totalTax": {
 *           "amount": "0",
 *           "convertedAmount": "0",
 *           "formattedAmount": "€0.00",
 *           "formattedConvertedAmount": "€0.00"
 *         },
 *         "rateBreakdown": []
 *       },
 *       "discount": {
 *         "amount": "0",
 *         "convertedAmount": "0",
 *         "formattedAmount": "€0.00",
 *         "formattedConvertedAmount": "€0.00"
 *       },
 *       "descriptionLines": [],
 *       "media": "wix:image://v1/3c76e2_c5331f937348492a97df87b0a3b34ea4~mv2.jpg#originWidth=1000&originHeight=1000",
 *       "availability": {
 *         "status": "AVAILABLE"
 *       },
 *       "physicalProperties": {
 *         "sku": "364115376135191",
 *         "shippable": true
 *       },
 *       "couponScopes": [
 *         {
 *           "namespace": "stores",
 *           "group": {
 *             "name": "collection",
 *             "entityId": "00000000-000000-000000-000000000001"
 *           }
 *         },
 *         {
 *           "namespace": "stores",
 *           "group": {
 *             "name": "product",
 *             "entityId": "c8539b66-7a44-fe18-affc-afec4be8562a"
 *           }
 *         }
 *       ],
 *       "itemType": {
 *         "preset": "PHYSICAL"
 *       },
 *       "paymentOption": "FULL_PAYMENT_ONLINE",
 *       "rootCatalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a"
 *     }
 *   ],
 *   "shippingInfo": {
 *     "carrierServiceOptions": []
 *   },
 *   "buyerNote": "Please gift wrap this order. Thanks!",
 *   "buyerInfo": {
 *     "contactId": "a4bc8d90-a91b-467f-a775-77d65dd0442e",
 *     "email": "johnnydoe@example.com",
 *     "memberId": "ea3d74df-b7dc-4ca1-a7c9-c416b9017a86"
 *   },
 *   "conversionCurrency": "EUR",
 *   "priceSummary": {
 *     "subtotal": {
 *       "amount": "30",
 *       "convertedAmount": "30",
 *       "formattedAmount": "€30.00",
 *       "formattedConvertedAmount": "€30.00"
 *     },
 *     "shipping": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "tax": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "discount": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "total": {
 *       "amount": "30",
 *       "convertedAmount": "30",
 *       "formattedAmount": "€30.00",
 *       "formattedConvertedAmount": "€30.00"
 *     },
 *     "additionalFees": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     }
 *   },
 *   "calculationErrors": {
 *     "orderValidationErrors": []
 *   },
 *   "appliedDiscounts": [
 *     {
 *       "discountType": "GLOBAL",
 *       "lineItemIds": [],
 *       "coupon": {
 *         "_id": "fbb94b06-7447-4161-9c48-59bfcdc39e77",
 *         "code": "SUMMERSALE10",
 *         "amount": {
 *           "amount": "10.0",
 *           "convertedAmount": "10.0",
 *           "formattedAmount": "€10.00",
 *           "formattedConvertedAmount": "€10.00"
 *         },
 *         "name": "SUMMERSALE10",
 *         "couponType": "MoneyOff"
 *       }
 *     }
 *   ],
 *   "customFields": [],
 *   "weightUnit": "KG",
 *   "currency": "EUR",
 *   "channelType": "WEB",
 *   "siteLanguage": "en",
 *   "buyerLanguage": "en",
 *   "completed": false,
 *   "taxIncludedInPrice": false,
 *   "createdBy": {
 *     "memberId": "ea3d74df-b7dc-4ca1-a7c9-c416b9017a86"
 *   },
 *   "_createdDate": "2023-02-22T15:49:04.627Z",
 *   "_updatedDate": "2023-02-22T16:30:58.947Z",
 *   "payNow": {
 *     "subtotal": {
 *       "amount": "30",
 *       "convertedAmount": "30",
 *       "formattedAmount": "€30.00",
 *       "formattedConvertedAmount": "€30.00"
 *     },
 *     "shipping": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "tax": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "discount": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "total": {
 *       "amount": "30",
 *       "convertedAmount": "30",
 *       "formattedAmount": "€30.00",
 *       "formattedConvertedAmount": "€30.00"
 *     },
 *     "additionalFees": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     }
 *   },
 *   "payLater": {
 *     "subtotal": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "shipping": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "tax": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "discount": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "total": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     },
 *     "additionalFees": {
 *       "amount": "0",
 *       "convertedAmount": "0",
 *       "formattedAmount": "€0.00",
 *       "formattedConvertedAmount": "€0.00"
 *     }
 *   },
 *   "membershipOptions": {
 *     "eligibleMemberships": [],
 *     "invalidMemberships": [],
 *     "selectedMemberships": {
 *       "memberships": []
 *     }
 *   },
 *   "additionalFees": [],
 *   "payNowTotalAfterGiftCard": {
 *     "amount": "30",
 *     "convertedAmount": "30",
 *     "formattedAmount": "€30.00",
 *     "formattedConvertedAmount": "€30.00"
 *   }
 * } 
 */
```

---