Introduction

Note: This module is universal. Functions in this module can run on both the backend and frontend.

The eCommerce Checkout API provides functionality for creating, retrieving. and managing a checkout.

The checkout is the second phase of an eCommerce purchase flow, coming after cart and before order. A checkout holds information about items to be purchased, price and tax summaries, shipping and billing info, any applied discounts, and more.

Before you begin

Some fields in the Stores Cart API cart object are held in the checkout object. For more info, refer to the Stores Cart to eCommerce Checkout Conversion Table.

To use the Wix eCommerce Checkout API, import { checkout } from the wix-ecom-backend module:

Copy
import { checkout } from "wix-ecom-backend";
Did this help?

Stores Cart to eCommerce Checkout Conversion Table

Some fields in the the Stores Cart API cart object are now held in the eCommerce Checkout API checkout object. To learn more, refer to the table below for changes in name and/or location.

The address object used in the eCommerce APIs is slightly different to the one used in the Stores APIs. For more details, refer to the address object conversion table.

Fields that remain with the same name, in the same location, and with no changes in behavior are marked with an asterisk (*).

Stores Cart ObjecteCommerce Checkout Object
id-
status-
weightUnit *weightUnit
buyerNote *buyerNote
currency.codecurrency
currency.symbolNo longer returned. Instead, for every price returned, we also provide the formatted price in checkout.priceSummary and/or order.priceSummary.
billingAddress.addressbillingInfo.address - See address object conversion table for more details.
billingAddress.contactDetails.firstNamebillingInfo.contactDetails.firstName
billingAddress.contactDetails.lastNamebillingInfo.contactDetails.lastName
billingAddress.contactDetails.phonebillingInfo.contactDetails.phone
billingAddress.contactDetails.companybillingInfo.contactDetails.company
billingAddress.contactDetails.vatIdbillingInfo.contactDetails.vatId
billingAddress.contactDetails.emailbillingInfo.buyerInfo.email
appliedCoupon.couponIdappliedDiscounts[i].coupon._id - The coupon is now an item in the appliedDiscounts array. To get it, search the appliedDiscounts array for the coupon field.
appliedCoupon.codeappliedDiscounts[i].coupon.code - The coupon is now an item in the appliedDiscounts array. To get it, search the appliedDiscounts array for the coupon field.
appliedCoupon.nameappliedDiscounts[i].coupon.name - The coupon is now an item in the appliedDiscounts array. To get it, search the appliedDiscounts array for the coupon field.
appliedCoupon.discountValueappliedDiscounts[i].coupon.amount.amount - The coupon is now an item in the appliedDiscounts array. To get it, search the appliedDiscounts array for the coupon field.
appliedCoupon.couponTypeNo longer returned.
totals.subtotalpriceSummary.subtotal.amount
totals.shippingpriceSummary.shipping.amount
totals.taxpriceSummary.tax.amount
totals.discountpriceSummary.discount.amount
totals.totalpriceSummary.total.amount
totals.weightlineItems[i].physicalProperties.weight X lineItems[i].quantity
totals.quantitylineItems[0].quantity + lineItems[1].quantity + lineItems[2].quantity
convertedTotals.subtotalpriceSummary.subtotal.convertedAmount
convertedTotals.shippingpriceSummary.shipping.convertedAmount
convertedTotals.taxpriceSummary.tax.convertedAmount
convertedTotals.discountpriceSummary.discount.convertedAmount
convertedTotals.totalpriceSummary.total.convertedAmount
convertedTotals.weightNo weight conversion in checkout. Same value as Stores cart.totals.weight.
convertedTotals.quantitySame value as Stores cart.totals.quantity.
shippingInfo.shippingRuleDetails.ruleIdֿֿֿֿֿֿֿֿshippingInfo.region._id
shippingInfo.shippingRuleDetails.optionIdֿֿֿֿֿֿֿֿshippingInfo.selectedCarrierServiceOption.title
shippingInfo.shippingRuleDetails.deliveryOptionֿֿֿֿֿֿֿֿshippingInfo.selectedCarrierServiceOption.title
shippingInfo.shippingRuleDetails.estimatedDeliveryTimeֿֿֿֿֿֿֿֿshippingInfo.logistics.deliveryTime
shippingInfo.pickupDetails.pickupAddressshippingInfo.selectedCarrierServiceOption.logistics.pickupDetails.address - See address object conversion table for more details.
shippingInfo.pickupDetails.buyerDetails.firstNameshippingInfo.shippingDestination.contactDetails.firstName
shippingInfo.pickupDetails.buyerDetails.lastNameshippingInfo.shippingDestination.contactDetails.lastName
shippingInfo.pickupDetails.buyerDetails.emailbuyerInfo.email
shippingInfo.pickupDetails.buyerDetails.phoneshippingInfo.shippingDestination.contactDetails.phone
shippingInfo.pickupDetails.pickupInstructionsshippingInfo.logistics.instructions
shippingInfo.shippingAddress.addressshippingInfo.shippingDestination.address - See address object conversion table for more details.
shippingInfo.shippingAddress.contactDetailsshippingInfo.shippingDestination.contactDetails
buyerInfo.id and buyerInfo.identityType: CONTACTbuyerInfo.contactId only.
buyerInfo.id and buyerInfo.identityType: VISITORbuyerInfo.visitorId only.
buyerInfo.id and buyerInfo.identityType: MEMBERbuyerInfo.memberId only.
buyerInfo.email *buyerInfo.email
buyerInfo.phonebillingInfo.contactDetails.phone
buyerInfo.firstNamebillingInfo.contactDetails.firstName
buyerInfo.lastNamebillingInfo.contactDetails.lastName
lineItems[i].idlineItems[i]._id - Note: this _id is of type GUID. In the Stores Cart API, the id is of type Int32.
lineItems[i].productIdlineItems[i].catalogReference.catalogItemId
lineItems[i].namelineItems[i].productName.original
lineItems[i].quantity*lineItems[i].quantity
lineItems[i].weightlineItems[i].physicalProperties.weight
lineItems[i].skulineItems[i].physicalProperties.sku
lineItems[i].lineItemType: "PHYSICAL"lineItems[i].itemType.preset: "PHYSICAL"
lineItems[i].lineItemType: "DIGITAL"lineItems[i].itemType.preset: "DIGITAL"
lineItems[i].lineItemType: "CUSTOM_AMOUNT_ITEMlineItems[i].itemType.custom and lineItems[i].catalogReference is empty.
lineItems[i].noteslineItems[i].descriptionLines[i].plainText.original
lineItems[i].customTextFieldslineItems[i].descriptionLines
lineItems[i].mediaItem.mediaTypeAll line item media in the eCommerce Cart, Checkout, and Order APIs are images.
lineItems[i].mediaItem.urllineItems[i].media.url
lineItems[i].mediaItem.widthlineItems[i].media.width
lineItems[i].mediaItem.heightlineItems[i].media.height
lineItems[i].optionslineItems[i].catalogReference.options
lineItems[i].priceData.pricelineItems[i].price.amount
lineItems[i].priceData.totalPricelineItems[i].price.amount X lineItems[i].quantity
lineItems[i].convertedPriceData.pricelineItems[i].price.convertedAmount
lineItems[i].convertedPriceData.totalPricelineItems[i].price.convertedAmount X lineItems[i].quantity
Did this help?

addToCheckout( )


Adds catalog line items and/or custom line items to a checkout.

The addToCheckout() function returns a Promise that resolves to the updated checkout when the specified items have been added.

Note: When adding catalog items, options.lineItems.catalogReference is required.

Permissions
Manage eCommerce - all permissions
Manage Stores - all permissions
Manage Orders
Manage Restaurants - all permissions
Manage eCommerce - Admin Permissions
Learn more about app permissions.
Method Declaration
Copy
function addToCheckout(
  _id: string,
  options: AddToCheckoutOptions,
): Promise<AddToCheckoutResponse>;
Method Parameters
_idstringRequired

Checkout ID.


optionsAddToCheckoutOptions

Items to be added to checkout.

Returns
Return Type:Promise<AddToCheckoutResponse>
JavaScript
/************************************** * Backend code - my-backend-file.jsw * *************************************/ import { checkout } from "wix-ecom-backend"; export async function myAddToCheckoutFunction(_id, options) { try { const updatedCheckout = await checkout.addToCheckout(_id, options); console.log("Success! Updated checkout:", updatedCheckout); return updatedCheckout; } catch (error) { console.error(error); // Handle the error } } /************* * Page code * ************/ import { myAddToCheckoutFunction } from "backend/my-backend-file"; // Sample checkout ID: const _id = "63879d9f-0d1c-49aa-a0c5-5fc612a24ec7"; // Sample addToCheckout options: const options = { lineItems: [ { catalogReference: { // Wix Stores appId appId: "215238eb-22a5-4c36-9e7b-e7c08025e04e", // Wix Stores productId catalogItemId: "df19c1f7-07d8-a265-42f8-e8dfa824cc6e", // Wix Stores variantId options: { variantId: "e62fee23-7878-437a-bf0e-292f17d11cb5", }, }, quantity: 1, }, ], }; myAddToCheckoutFunction(_id, options) .then((updatedCheckout) => { const checkoutSubtotal = updatedCheckout.priceSummary.subtotal.amount; const numberOfCheckoutLineItems = updatedCheckout.lineItems.length; console.log("Success! Updated checkout:", updatedCheckout); return updatedCheckout; }) .catch((error) => { console.error(error); // Handle the error }); /* Promise resolves to: * * { * "_id": "63879d9f-0d1c-49aa-a0c5-5fc612a24ec7", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000001", * "quantity": 1, * "catalogReference": { * "catalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e" * }, * "productName": { * "original": "Shirt", * "translated": "Shirt" * }, * "url": "https://example.wixsite.com/ep-tester/product-page/shirt", * "price": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "lineItemPrice": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.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": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "totalPriceBeforeTax": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "taxDetails": { * "taxableAmount": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.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" * }, * { * "_id": "00000000-0000-0000-0000-000000000002", * "quantity": 1, * "catalogReference": { * "catalogItemId": "df19c1f7-07d8-a265-42f8-e8dfa824cc6e", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", * "options": { * "variantId": "e62fee23-7878-437a-bf0e-292f17d11cb5" * } * }, * "productName": { * "original": "Shoe", * "translated": "Shoe" * }, * "url": "https://example.wixsite.com/ep-tester/product-page/shoe", * "price": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "lineItemPrice": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "fullPrice": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "priceBeforeDiscounts": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "totalPriceAfterTax": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "totalPriceBeforeTax": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "taxDetails": { * "taxableAmount": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.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": [ * { * "name": { * "original": "Color", * "translated": "Color" * }, * "colorInfo": { * "original": "Black", * "translated": "Black", * "code": "#000" * }, * "lineType": "COLOR", * "color": "Black" * } * ], * "media": "wix:image://v1/3c76e2_bf235c38610f4d2a905db71095b351cf~mv2.jpg#originWidth=1000&originHeight=1000", * "availability": { * "status": "AVAILABLE", * "quantityAvailable": 30 * }, * "physicalProperties": { * "sku": "364215376135191", * "shippable": true * }, * "couponScopes": [ * { * "namespace": "stores", * "group": { * "name": "collection", * "entityId": "00000000-000000-000000-000000000001" * } * }, * { * "namespace": "stores", * "group": { * "name": "product", * "entityId": "df19c1f7-07d8-a265-42f8-e8dfa824cc6e" * } * } * ], * "itemType": { * "preset": "PHYSICAL" * }, * "paymentOption": "FULL_PAYMENT_ONLINE", * "rootCatalogItemId": "df19c1f7-07d8-a265-42f8-e8dfa824cc6e" * } * ], * "shippingInfo": { * "carrierServiceOptions": [] * }, * "buyerInfo": { * "contactId": "f7dc17a6-825a-466e-a78e-c4abea0217db", * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873" * }, * "conversionCurrency": "USD", * "priceSummary": { * "subtotal": { * "amount": "95", * "convertedAmount": "95", * "formattedAmount": "$95.00", * "formattedConvertedAmount": "$95.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": "95", * "convertedAmount": "95", * "formattedAmount": "$95.00", * "formattedConvertedAmount": "$95.00" * }, * "additionalFees": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * } * }, * "calculationErrors": { * "orderValidationErrors": [] * }, * "appliedDiscounts": [], * "customFields": [], * "weightUnit": "KG", * "currency": "USD", * "channelType": "WEB", * "siteLanguage": "en", * "buyerLanguage": "en", * "completed": false, * "taxIncludedInPrice": false, * "createdBy": { * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873" * }, * "_createdDate": "2023-01-04T15:11:20.762Z", * "_updatedDate": "2023-01-04T15:15:24.035Z", * "payNow": { * "subtotal": { * "amount": "95", * "convertedAmount": "95", * "formattedAmount": "$95.00", * "formattedConvertedAmount": "$95.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": "95", * "convertedAmount": "95", * "formattedAmount": "$95.00", * "formattedConvertedAmount": "$95.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": "95", * "convertedAmount": "95", * "formattedAmount": "$95.00", * "formattedConvertedAmount": "$95.00" * } * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

createCheckout( )


Creates a checkout.

The createCheckout() function returns a Promise that resolves to the new checkout when it's created.

Notes:

  • Checkout must include at least 1 item in the options.lineItems array.
  • options.channelType is required.
  • If _id for options.lineItems is added, make sure that each _id is unique.
  • If options.checkoutInfo.customFields are added, then options.checkoutInfo.customFields.value is required.
Permissions
Manage eCommerce - all permissions
Manage Stores - all permissions
Manage Orders
Manage Restaurants - all permissions
Manage eCommerce - Admin Permissions
Learn more about app permissions.
Method Declaration
Copy
function createCheckout(options: CreateCheckoutOptions): Promise<Checkout>;
Method Parameters
optionsCreateCheckoutOptions

Checkout creation options.

Returns
Return Type:Promise<Checkout>
JavaScript
/************************************** * Backend code - my-backend-file.jsw * *************************************/ import { checkout } from "wix-ecom-backend"; export async function myCreateCheckoutFunction(options) { try { const newCheckout = await checkout.createCheckout(options); console.log("Success! Checkout created, checkout:", newCheckout); return newCheckout; } catch (error) { console.error(error); // Handle the error } } /************* * Page code * ************/ import { myCreateCheckoutFunction } from "backend/my-backend-file"; // Sample options object: const options = { lineItems: [ { quantity: 3, catalogReference: { // Wix Stores appId appId: "215238eb-22a5-4c36-9e7b-e7c08025e04e", // Wix Stores productId catalogItemId: "c8539b66-7a44-fe18-affc-afec4be8562a", }, }, ], channelType: "WEB", }; myCreateCheckoutFunction(options) .then((newCheckout) => { console.log("Success! Checkout created:", newCheckout); return newCheckout; }) .catch((error) => { console.error(error); // Handle the error }); /* Promise resolves to: * * { * "_id": "8a27ba84-0814-4b0e-8db3-b6057a421bd9", * "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://example.wixsite.com", * "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": [] * }, * "buyerInfo": { * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873" * }, * "conversionCurrency": "USD", * "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" * } * }, * "calculationErrors": { * "orderValidationErrors": [] * }, * "appliedDiscounts": [], * "customFields": [], * "weightUnit": "KG", * "currency": "USD", * "channelType": "WEB", * "siteLanguage": "en", * "buyerLanguage": "en", * "completed": false, * "taxIncludedInPrice": false, * "createdBy": { * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873" * }, * "_createdDate": "2022-07-18T13:39:03.023Z", * "_updatedDate": "2022-07-18T13:39:03.023Z", * "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" * } * }, * "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" * } * }, * "membershipOptions": { * "eligibleMemberships": [], * "invalidMemberships": [], * "selectedMemberships": { * "memberships": [] * } * } * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

createOrder( )


Creates an order from a specified checkout.

The createOrder() function returns a Promise that resolves to the new order's ID and paymentGatewayOrderID when the order is created. Pass the paymentGatewayOrderId as the paymentId param to the startPayment() function to allow a customer to pay for their order.

Note: The following requirements must be met for an order to be created from a checkout.

  • A checkout cannot have calculation errors. Pass the checkout._id to Get Checkout and take a look at the calculationErrors field.
  • A checkout must have at least 1 line item.
  • All of the line Items have an availability.status of "AVAILABLE" or "PARTIALLY_AVAILABLE".
  • If there is a payment to be made, meaning that priceSummary.total is greater than 0, the billingInfo.address field must be provided.
  • When a checkout has line items to be shipped, the shippingInfo.shippingDestination.address and shippingInfo.selectedCarrierServiceOption fields must be provided.
  • When a checkout has line items for pickup, the shippingInfo.selectedCarrierServiceOption.logistics.pickupDetails field must be provided.
Permissions
Manage eCommerce - all permissions
Manage Stores - all permissions
Manage Orders
Manage Restaurants - all permissions
Learn more about app permissions.
Method Declaration
Copy
function createOrder(
  _id: string,
  options: CreateOrderOptions,
): Promise<CreateOrderResponse>;
Method Parameters
_idstringRequired

Checkout ID.


optionsCreateOrderOptions

Further order creation options.

Returns
Return Type:Promise<CreateOrderResponse>
JavaScript
/************************************** * Backend code - my-backend-file.jsw * *************************************/ import { checkout } from "wix-ecom-backend"; export async function myCreateOrderFromCheckoutFunction(checkoutId) { try { const createOrderResponse = await checkout.createOrder(checkoutId); console.log("Success! Created an order from the checkout"); return createOrderResponse; } catch (error) { console.error(error); // Handle the error } } /************* * Page code * ************/ import { myCreateOrderFromCheckoutFunction } from "backend/my-backend-file"; // Sample checkoutId: const checkoutId = "23a7b29a-3c14-4ef1-9353-f4b714b13217"; myCreateOrderFromCheckoutFunction(checkoutId) .then((createOrderResponse) => { const orderId = createOrderResponse.orderId; const paymentGatewayOrderId = createOrderResponse.paymentGatewayOrderId; console.log("Success! Created an order from the checkout"); return createOrderResponse; }) .catch((error) => { console.error(error); // Handle the error }); /* Promise resolves to: * * { * "orderId": "02843248-495f-45c0-a5d6-e913f647c9f2", * "paymentGatewayOrderId": "f30440f4-413a-4382-bc38-7280b155a5ed" * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

getCheckout( )


Retrieves a checkout.

The getCheckout() function returns a Promise that resolves when the specified checkout is retrieved.

Permissions
Manage eCommerce - all permissions
Read eCommerce - all read permissions
Manage Stores - all permissions
Read Stores - all read permissions
Manage Orders
Read Orders
Manage Restaurants - all permissions
Learn more about app permissions.
Method Declaration
Copy
function getCheckout(
  _id: string,
  options: GetCheckoutOptions,
): Promise<Checkout>;
Method Parameters
_idstringRequired

Checkout ID.


optionsGetCheckoutOptions
Returns
Return Type:Promise<Checkout>
JavaScript
/************************************** * Backend code - my-backend-file.jsw * *************************************/ import { checkout } from "wix-ecom-backend"; export async function myGetCheckoutFunction(checkoutId) { try { const retrievedCheckout = await checkout.getCheckout(checkoutId); console.log("Success! Retrieved checkout:", retrievedCheckout); return retrievedCheckout; } catch (error) { console.error(error); // Handle the error } } /************* * Page code * ************/ import { myGetCheckoutFunction } from "backend/my-backend-file"; // Sample checkoutId: const checkoutId = "74cc6825-82a1-4f1f-9fbb-7d73f6be152a"; myGetCheckoutFunction(checkoutId) .then((checkout) => { const formattedCheckoutTotal = checkout.subtotal.formattedAmount; const numOfCheckoutLineItems = checkout.lineItems.length; console.log("Success! Retrieved checkout:", checkout); return checkout; }) .catch((error) => { console.error(error); // Handle the error }); /* Promise resolves to: * * { * "_id": "74cc6825-82a1-4f1f-9fbb-7d73f6be152a", * "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://example.wixsite.com", * "price": { * "amount": "10.00", * "convertedAmount": "10.00", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "lineItemPrice": { * "amount": "30.00", * "convertedAmount": "30.00", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "fullPrice": { * "amount": "10.00", * "convertedAmount": "10.00", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "priceBeforeDiscounts": { * "amount": "10.00", * "convertedAmount": "10.00", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "totalPriceAfterTax": { * "amount": "20.0", * "convertedAmount": "20.0", * "formattedAmount": "$20.00", * "formattedConvertedAmount": "$20.00" * }, * "totalPriceBeforeTax": { * "amount": "20.0", * "convertedAmount": "20.0", * "formattedAmount": "$20.00", * "formattedConvertedAmount": "$20.00" * }, * "taxDetails": { * "taxableAmount": { * "amount": "20.0", * "convertedAmount": "20.0", * "formattedAmount": "$20.00", * "formattedConvertedAmount": "$20.00" * }, * "taxRate": "0.0", * "totalTax": { * "amount": "0.0", * "convertedAmount": "0.0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "rateBreakdown": [] * }, * "discount": { * "amount": "10.0", * "convertedAmount": "10.0", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.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" * }, * { * "_id": "00000000-0000-0000-0000-000000000002", * "quantity": 1, * "catalogReference": { * "catalogItemId": "df19c1f7-07d8-a265-42f8-e8dfa824cc6e", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", * "options": { * "variantId": "2f430d69-9b75-4874-bfbd-c5f6fa5aff3d", * "customTextFields": { * "birthday card": "Happy Birthday!" * } * } * }, * "productName": { * "original": "Shoe", * "translated": "Shoe" * }, * "url": "https://example.wixsite.com", * "price": { * "amount": "85.00", * "convertedAmount": "85.00", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "lineItemPrice": { * "amount": "85.00", * "convertedAmount": "85.00", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "fullPrice": { * "amount": "85.00", * "convertedAmount": "85.00", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "priceBeforeDiscounts": { * "amount": "85.00", * "convertedAmount": "85.00", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "totalPriceAfterTax": { * "amount": "85.00", * "convertedAmount": "85.00", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "totalPriceBeforeTax": { * "amount": "85.00", * "convertedAmount": "85.00", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "taxDetails": { * "taxableAmount": { * "amount": "85.00", * "convertedAmount": "85.00", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "taxRate": "0.0", * "totalTax": { * "amount": "0.0", * "convertedAmount": "0.0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "rateBreakdown": [] * }, * "discount": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "descriptionLines": [ * { * "name": { * "original": "Color", * "translated": "Color" * }, * "colorInfo": { * "original": "Brown", * "translated": "Brown", * "code": "#783f04" * }, * "lineType": "COLOR", * "color": "Brown" * }, * { * "name": { * "original": "birthday card", * "translated": "birthday card" * }, * "plainText": { * "original": "Happy Birthday!", * "translated": "Happy Birthday!" * }, * "lineType": "PLAIN_TEXT", * "plainTextValue": { * "original": "Happy Birthday!", * "translated": "Happy Birthday!" * } * } * ], * "media": "wix:image://v1/3c76e2_bf235c38610f4d2a905db71095b351cf~mv2.jpg#originWidth=1000&originHeight=1000", * "availability": { * "status": "AVAILABLE", * "quantityAvailable": 30 * }, * "physicalProperties": { * "sku": "364215376135191", * "shippable": true * }, * "couponScopes": [ * { * "namespace": "stores", * "group": { * "name": "collection", * "entityId": "00000000-000000-000000-000000000001" * } * }, * { * "namespace": "stores", * "group": { * "name": "product", * "entityId": "df19c1f7-07d8-a265-42f8-e8dfa824cc6e" * } * } * ], * "itemType": { * "preset": "PHYSICAL" * }, * "paymentOption": "FULL_PAYMENT_ONLINE", * "rootCatalogItemId": "df19c1f7-07d8-a265-42f8-e8dfa824cc6e" * }, * { * "_id": "00000000-0000-0000-0000-000000000003", * "quantity": 1, * "catalogReference": { * "catalogItemId": "9fe8c5b2-9c94-7153-ebb9-8533695e2b6f", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", * "options": { * "Size": "Large", * "Color": "White" * } * }, * "price": { * "amount": "", * "convertedAmount": "", * "formattedAmount": "", * "formattedConvertedAmount": "" * }, * "fullPrice": { * "amount": "", * "convertedAmount": "", * "formattedAmount": "", * "formattedConvertedAmount": "" * }, * "priceBeforeDiscounts": { * "amount": "", * "convertedAmount": "", * "formattedAmount": "", * "formattedConvertedAmount": "" * }, * "descriptionLines": [], * "availability": { * "status": "NOT_FOUND" * }, * "couponScopes": [], * "paymentOption": "FULL_PAYMENT_ONLINE" * } * ], * "billingInfo": { * "address": { * "addressLine1": "235 West 23rd Street", * "addressLine2": "3rd floor", * "city": "New York", * "subdivision": "US-NY", * "country": "US", * "postalCode": "10011" * }, * "contactDetails": { * "firstName": "Jane", * "lastName": "Doe", * "phone": "+1234567890" * } * }, * "shippingInfo": { * "shippingDestination": { * "address": { * "addressLine1": "235 West 23rd Street", * "addressLine2": "3rd floor", * "city": "New York", * "subdivision": "US-NY", * "country": "US", * "postalCode": "10011" * }, * "contactDetails": { * "firstName": "Jane", * "lastName": "Doe", * "phone": "+1234567890" * } * }, * "selectedCarrierServiceOption": { * "code": "ed5bbce2-9533-dff4-7db0-13702fd139c5", * "title": "Standard US Shipping", * "logistics": { * "deliveryTime": "" * }, * "cost": { * "totalPriceAfterTax": { * "amount": "10.0", * "convertedAmount": "10.0", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "totalPriceBeforeTax": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "taxDetails": { * "taxRate": "0.0", * "totalTax": { * "amount": "0.0", * "convertedAmount": "0.0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "rateBreakdown": [] * }, * "price": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * } * }, * "requestedShippingOption": true, * "otherCharges": [], * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc" * }, * "region": { * "_id": "009fbe5d-89d3-7825-cbbf-1aab4d908b73", * "name": "USA shipping" * }, * "carrierServiceOptions": [ * { * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc", * "shippingOptions": [ * { * "code": "ed5bbce2-9533-dff4-7db0-13702fd139c5", * "title": "Standard US Shipping", * "logistics": { * "deliveryTime": "" * }, * "cost": { * "price": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "otherCharges": [] * } * } * ] * } * ] * }, * "buyerNote": "Please wrap it up as a present", * "buyerInfo": { * "contactId": "f7dc17a6-825a-466e-a78e-c4abea0217db", * "email": "Janedoe@example.com", * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873" * }, * "conversionCurrency": "USD", * "priceSummary": { * "subtotal": { * "amount": "115.00", * "convertedAmount": "115.00", * "formattedAmount": "$115.00", * "formattedConvertedAmount": "$115.00" * }, * "shipping": { * "amount": "10.0", * "convertedAmount": "10.0", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "tax": { * "amount": "0.0", * "convertedAmount": "0.0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "discount": { * "amount": "10.0", * "convertedAmount": "10.0", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "total": { * "amount": "115.00", * "convertedAmount": "115.00", * "formattedAmount": "$115.00", * "formattedConvertedAmount": "$115.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": [ * { * "value": "12345", * "title": "Tax ID", * "translatedTitle": "Tax ID" * } * ], * "weightUnit": "KG", * "currency": "USD", * "channelType": "WEB", * "siteLanguage": "en", * "buyerLanguage": "en", * "completed": false, * "taxIncludedInPrice": false, * "createdBy": { * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873" * }, * "_createdDate": "2022-07-18T13:25:22.141Z", * "_updatedDate": "2022-07-18T13:25:22.216Z", * "payNow": { * "subtotal": { * "amount": "115.00", * "convertedAmount": "115.00", * "formattedAmount": "$115.00", * "formattedConvertedAmount": "$115.00" * }, * "shipping": { * "amount": "10.0", * "convertedAmount": "10.0", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "tax": { * "amount": "0.0", * "convertedAmount": "0.0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "discount": { * "amount": "10.0", * "convertedAmount": "10.0", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "total": { * "amount": "115.00", * "convertedAmount": "115.00", * "formattedAmount": "$115.00", * "formattedConvertedAmount": "$115.00" * } * }, * "payLater": { * "subtotal": { * "amount": "0.00", * "convertedAmount": "0.00", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "shipping": { * "amount": "0.0", * "convertedAmount": "0.0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "tax": { * "amount": "0.0", * "convertedAmount": "0.0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "discount": { * "amount": "0.0", * "convertedAmount": "0.0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "total": { * "amount": "0.00", * "convertedAmount": "0.00", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * } * }, * "membershipOptions": { * "eligibleMemberships": [], * "invalidMemberships": [], * "selectedMemberships": { * "memberships": [] * } * } * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

getCheckoutUrl( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Retrieves the checkout page URL of a specified checkout.

By default, a checkoutUrl generates for a checkout and directs to a standard Wix checkout page. However, if overrideCheckoutUrl has a value, it will replace and set the value of checkoutUrl.

Permissions
Manage eCommerce - all permissions
Read eCommerce - all read permissions
Manage Stores - all permissions
Read Stores - all read permissions
Manage Orders
Read Orders
Manage Restaurants - all permissions
Learn more about app permissions.
Method Declaration
Copy
function getCheckoutUrl(
  _id: string,
  options: GetCheckoutUrlOptions,
): Promise<GetCheckoutURLResponse>;
Method Parameters
_idstringRequired

Checkout ID.


optionsGetCheckoutUrlOptions
Returns
Return Type:Promise<GetCheckoutURLResponse>
JavaScript
import { checkout } from "wix-ecom-backend"; async function getCheckoutUrl(id, options) { try { const result = await checkout.getCheckoutUrl(id, options); return result; } catch (error) { console.error(error); // Handle the error } }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

markCheckoutAsCompleted( )


Marks a checkout as completed - checkout.complete boolean is set to true.

The markCheckoutAsCompleted() function returns a Promise that resolves when the specified checkout is marked as completed.

Permissions
Manage eCommerce - all permissions
Manage Stores - all permissions
Manage Orders
Manage Restaurants - all permissions
Learn more about app permissions.
Method Declaration
Copy
function markCheckoutAsCompleted(_id: string): Promise<void>;
Method Parameters
_idstringRequired

Checkout ID.

JavaScript
/************************************** * Backend code - my-backend-file.jsw * *************************************/ import { checkout } from "wix-ecom-backend"; export async function myMarkCheckoutAsCompletedFunction(checkoutId) { try { await checkout.markCheckoutAsCompleted(checkoutId); console.log("Success! Checkout marked as completed"); return; } catch (error) { console.error(error); // Handle the error } } /************* * Page code * ************/ import { myMarkCheckoutAsCompletedFunction } from "backend/my-backend-file"; // Sample checkoutId: const checkoutId = "96a61a4b-6b61-47d1-a039-0213a8230ccd"; myMarkCheckoutAsCompletedFunction(checkoutId) .then(() => { console.log("Success! Checkout marked as completed"); return; }) .catch((error) => { console.error(error); // Handle the error });
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

removeCoupon( )


Removes the coupon from a specified checkout.

The removeCoupon() function returns a Promise that resolves to the updated checkout when the coupon is removed from the specified checkout.

Note: A checkout can only hold 1 coupon.

Permissions
Manage eCommerce - all permissions
Manage Stores - all permissions
Manage Orders
Manage Restaurants - all permissions
Learn more about app permissions.
Method Declaration
Copy
function removeCoupon(_id: string): Promise<RemoveCouponResponse>;
Method Parameters
_idstringRequired

ID of the checkout to remove the coupon from.

Returns
Return Type:Promise<RemoveCouponResponse>
JavaScript
/************************************** * Backend code - my-backend-file.jsw * **************************************/ import { checkout } from "wix-ecom-backend"; export async function myRemoveCouponFunction(checkoutId) { try { const updatedCheckout = await checkout.removeCoupon(checkoutId); console.log("Success! Updated checkout:", updatedCheckout); return updatedCheckout; } catch (error) { console.error(error); // Handle the error } } /************* * Page code * ************/ import { myRemoveCouponFunction } from "backend/my-backend-file"; // Sample checkoutId: const checkoutId = "75b0d071-8ca0-4227-962f-91d0605c8c3a"; myRemoveCouponFunction(checkoutId) .then((updatedCheckout) => { const checkoutId = updatedCheckout._id; const appliedDiscounts = updatedCheckout.appliedDiscounts; // appliedCoupon boolean value is false if no coupon exists on checkout const appliedCoupon = appliedDiscounts.some(({ coupon }) => coupon); console.log("Success! Updated checkout:", updatedCheckout); return updatedCheckout; }) .catch((error) => { console.error(error); // Handle the error }); /* Promise resolves to: * * { * "_id": "75b0d071-8ca0-4227-962f-91d0605c8c3a", * "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://example.wixsite.com", * "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" * }, * { * "_id": "00000000-0000-0000-0000-000000000002", * "quantity": 1, * "catalogReference": { * "catalogItemId": "df19c1f7-07d8-a265-42f8-e8dfa824cc6e", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", * "options": { * "variantId": "2f430d69-9b75-4874-bfbd-c5f6fa5aff3d", * "customTextFields": { * "birthday card": "Happy Birthday!" * } * } * }, * "productName": { * "original": "Shoe", * "translated": "Shoe" * }, * "url": "https://example.wixsite.com", * "price": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "lineItemPrice": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "fullPrice": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "priceBeforeDiscounts": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "totalPriceAfterTax": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "totalPriceBeforeTax": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "taxDetails": { * "taxableAmount": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.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": [ * { * "name": { * "original": "Color", * "translated": "Color" * }, * "colorInfo": { * "original": "Brown", * "translated": "Brown", * "code": "#783f04" * }, * "lineType": "COLOR", * "color": "Brown" * }, * { * "name": { * "original": "birthday card", * "translated": "birthday card" * }, * "plainText": { * "original": "Happy Birthday!", * "translated": "Happy Birthday!" * }, * "lineType": "PLAIN_TEXT", * "plainTextValue": { * "original": "Happy Birthday!", * "translated": "Happy Birthday!" * } * } * ], * "media": "wix:image://v1/3c76e2_bf235c38610f4d2a905db71095b351cf~mv2.jpg#originWidth=1000&originHeight=1000", * "availability": { * "status": "AVAILABLE", * "quantityAvailable": 30 * }, * "physicalProperties": { * "sku": "364215376135191", * "shippable": true * }, * "couponScopes": [ * { * "namespace": "stores", * "group": { * "name": "collection", * "entityId": "00000000-000000-000000-000000000001" * } * }, * { * "namespace": "stores", * "group": { * "name": "product", * "entityId": "df19c1f7-07d8-a265-42f8-e8dfa824cc6e" * } * } * ], * "itemType": { * "preset": "PHYSICAL" * }, * "paymentOption": "FULL_PAYMENT_ONLINE", * "rootCatalogItemId": "df19c1f7-07d8-a265-42f8-e8dfa824cc6e" * }, * { * "_id": "00000000-0000-0000-0000-000000000003", * "quantity": 1, * "catalogReference": { * "catalogItemId": "9fe8c5b2-9c94-7153-ebb9-8533695e2b6f", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", * "options": { * "Size": "Large", * "Color": "White" * } * }, * "price": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "fullPrice": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "priceBeforeDiscounts": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "descriptionLines": [], * "availability": { * "status": "NOT_FOUND" * }, * "couponScopes": [], * "paymentOption": "FULL_PAYMENT_ONLINE" * } * ], * "billingInfo": { * "address": { * "addressLine1": "235 West 23rd Street", * "addressLine2": "3rd floor", * "city": "New York", * "subdivision": "US-NY", * "country": "US", * "postalCode": "10011" * }, * "contactDetails": { * "firstName": "Jane", * "lastName": "Doe", * "phone": "+1234567890" * } * }, * "shippingInfo": { * "shippingDestination": { * "address": { * "addressLine1": "235 West 23rd Street", * "addressLine2": "3rd floor", * "city": "New York", * "subdivision": "US-NY", * "country": "US", * "postalCode": "10011" * }, * "contactDetails": { * "firstName": "Jane", * "lastName": "Doe", * "phone": "+1234567890" * } * }, * "selectedCarrierServiceOption": { * "code": "ed5bbce2-9533-dff4-7db0-13702fd139c5", * "title": "Standard US Shipping", * "logistics": { * "deliveryTime": "" * }, * "cost": { * "totalPriceAfterTax": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "totalPriceBeforeTax": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "taxDetails": { * "taxRate": "0", * "totalTax": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "rateBreakdown": [] * }, * "price": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * } * }, * "requestedShippingOption": true, * "otherCharges": [], * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc" * }, * "region": { * "_id": "009fbe5d-89d3-7825-cbbf-1aab4d908b73", * "name": "USA shipping" * }, * "carrierServiceOptions": [ * { * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc", * "shippingOptions": [ * { * "code": "ed5bbce2-9533-dff4-7db0-13702fd139c5", * "title": "Standard US Shipping", * "logistics": { * "deliveryTime": "" * }, * "cost": { * "price": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "otherCharges": [] * } * } * ] * } * ] * }, * "buyerNote": "Please wrap it up as a present", * "buyerInfo": { * "contactId": "f7dc17a6-825a-466e-a78e-c4abea0217db", * "email": "Janedoe@example.com", * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873" * }, * "conversionCurrency": "USD", * "priceSummary": { * "subtotal": { * "amount": "115", * "convertedAmount": "115", * "formattedAmount": "$115.00", * "formattedConvertedAmount": "$115.00" * }, * "shipping": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.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": "125", * "convertedAmount": "125", * "formattedAmount": "$125.00", * "formattedConvertedAmount": "$125.00" * }, * "additionalFees": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * } * }, * "calculationErrors": { * "orderValidationErrors": [] * }, * "appliedDiscounts": [], * "customFields": [ * { * "value": "12345", * "title": "Tax ID", * "translatedTitle": "Tax ID" * } * ], * "weightUnit": "KG", * "currency": "USD", * "channelType": "WEB", * "siteLanguage": "en", * "buyerLanguage": "en", * "completed": false, * "taxIncludedInPrice": false, * "createdBy": { * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873" * }, * "_createdDate": "2022-10-19T14:22:03.847Z", * "_updatedDate": "2022-10-19T14:22:30.842Z", * "payNow": { * "subtotal": { * "amount": "115", * "convertedAmount": "115", * "formattedAmount": "$115.00", * "formattedConvertedAmount": "$115.00" * }, * "shipping": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.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": "125", * "convertedAmount": "125", * "formattedAmount": "$125.00", * "formattedConvertedAmount": "$125.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": [] * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

removeGiftCard( )


Removes the gift card from a specified checkout.

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.

Permissions
Manage eCommerce - all permissions
Manage Stores - all permissions
Manage Orders
Manage Restaurants - all permissions
Learn more about app permissions.
Method Declaration
Copy
function removeGiftCard(_id: string): Promise<RemoveGiftCardResponse>;
Method Parameters
_idstringRequired

ID of the checkout to remove the gift card from.

Returns
Return Type:Promise<RemoveGiftCardResponse>
JavaScript
/************************************** * Backend code - my-backend-file.jsw * **************************************/ import { checkout } from "wix-ecom-backend"; export async function myRemoveGiftCardFunction(checkoutId) { try { const updatedCheckout = await checkout.removeGiftCard(checkoutId); console.log("Success! Removed gift card from checkout:", updatedCheckout); return updatedCheckout; } catch (error) { console.error(error); // Handle the error } } /************* * Page code * ************/ import { myRemoveGiftCardFunction } from "backend/my-backend-file"; // Sample checkoutId: const checkoutId = "84d74a0e-5c3c-4113-8bd2-d264cc60d82a"; myRemoveGiftCardFunction(checkoutId) .then((updatedCheckout) => { const checkoutId = updatedCheckout._id; const totalPrice = updatedCheckout.priceSummary.total; console.log("Success! Removed gift card from checkout:", updatedCheckout); return updatedCheckout; }) .catch((error) => { console.error(error); // Handle the error }); /* Promise resolves to: * * { * "_id": "84d74a0e-5c3c-4113-8bd2-d264cc60d82a", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000001", * "quantity": 1, * "catalogReference": { * "catalogItemId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", * "options": { * "variantId": "132b84e8-aab8-47a1-a1f6-2c47557b64a4" * } * }, * "productName": { * "original": "Watch", * "translated": "Watch" * }, * "url": "https://example.wixsite.com", * "price": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "lineItemPrice": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "fullPrice": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "priceBeforeDiscounts": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.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": [ * { * "name": { * "original": "Size", * "translated": "Size" * }, * "plainText": { * "original": "Medium", * "translated": "Medium" * }, * "lineType": "PLAIN_TEXT", * "plainTextValue": { * "original": "Medium", * "translated": "Medium" * } * }, * { * "name": { * "original": "Color", * "translated": "Color" * }, * "colorInfo": { * "original": "Grey", * "translated": "Grey", * "code": "rgb(128, 128, 128)" * }, * "lineType": "COLOR", * "color": "Grey" * } * ], * "media": "wix:image://v1/3c76e2_8891bbe3372a428aac976ac59aa0ac74~mv2.jpg#originWidth=1000&originHeight=1000", * "availability": { * "status": "AVAILABLE" * }, * "physicalProperties": { * "sku": "217537123517253", * "shippable": true * }, * "couponScopes": [ * { * "namespace": "stores", * "group": { * "name": "collection", * "entityId": "00000000-000000-000000-000000000001" * } * }, * { * "namespace": "stores", * "group": { * "name": "product", * "entityId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09" * } * } * ], * "itemType": { * "preset": "PHYSICAL" * }, * "paymentOption": "FULL_PAYMENT_ONLINE", * "rootCatalogItemId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09" * } * ], * "billingInfo": { * "address": { * "addressLine1": "525 5th Avenue", * "city": "New York", * "subdivision": "US-NY", * "country": "US", * "postalCode": "10173" * }, * "contactDetails": { * "firstName": "Jane", * "lastName": "Doe", * "phone": "0555555555" * } * }, * "shippingInfo": { * "shippingDestination": { * "address": { * "addressLine1": "525 5th Avenue", * "city": "New York", * "subdivision": "US-NY", * "country": "US", * "postalCode": "10173" * }, * "contactDetails": { * "firstName": "Jane", * "lastName": "Doe", * "phone": "0555555555" * } * }, * "selectedCarrierServiceOption": { * "code": "ed5bbce2-9533-dff4-7db0-13702fd139c5", * "title": "Standard US Shipping", * "logistics": { * "deliveryTime": "" * }, * "cost": { * "totalPriceAfterTax": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "totalPriceBeforeTax": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "taxDetails": { * "taxRate": "0", * "totalTax": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "rateBreakdown": [] * }, * "price": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * } * }, * "requestedShippingOption": true, * "otherCharges": [], * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc" * }, * "region": { * "_id": "009fbe5d-89d3-7825-cbbf-1aab4d908b73", * "name": "USA shipping" * }, * "carrierServiceOptions": [ * { * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc", * "shippingOptions": [ * { * "code": "ed5bbce2-9533-dff4-7db0-13702fd139c5", * "title": "Standard US Shipping", * "logistics": { * "deliveryTime": "" * }, * "cost": { * "price": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "otherCharges": [] * } * } * ] * } * ] * }, * "buyerInfo": { * "contactId": "24de6f0b-60ce-4faa-9138-2e39f1415615", * "email": "janedoe@gmail.com", * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873" * }, * "conversionCurrency": "USD", * "priceSummary": { * "subtotal": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "shipping": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.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": "40", * "convertedAmount": "40", * "formattedAmount": "$40.00", * "formattedConvertedAmount": "$40.00" * }, * "additionalFees": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * } * }, * "calculationErrors": { * "orderValidationErrors": [] * }, * "appliedDiscounts": [], * "customFields": [], * "weightUnit": "KG", * "currency": "USD", * "channelType": "WEB", * "siteLanguage": "en", * "buyerLanguage": "en", * "completed": false, * "taxIncludedInPrice": false, * "createdBy": { * "visitorId": "4c7ce95c-9fb3-417d-9f02-b41e82b841f7" * }, * "_createdDate": "2022-10-27T08:51:44.099Z", * "_updatedDate": "2022-10-27T08:54:53.785Z", * "payNow": { * "subtotal": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "shipping": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.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": "40", * "convertedAmount": "40", * "formattedAmount": "$40.00", * "formattedConvertedAmount": "$40.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": [], * "cartId": "d7aca608-cbbd-4a22-9813-0459992abd1f" * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

removeLineItems( )


Removes line items from the specified checkout.

The removeLineItems() function returns a Promise that resolves to the updated checkout when the line items are removed from the specified checkout.

Permissions
Manage eCommerce - all permissions
Manage Stores - all permissions
Manage Orders
Manage Restaurants - all permissions
Learn more about app permissions.
Method Declaration
Copy
function removeLineItems(
  _id: string,
  lineItemIds: Array<string>,
): Promise<RemoveLineItemsResponse>;
Method Parameters
_idstringRequired

ID of the checkout to remove line items from.


lineItemIdsArray<string>Required

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>
JavaScript
/************************************** * Backend code - my-backend-file.jsw * **************************************/ import { checkout } from "wix-ecom-backend"; export async function myRemoveLineItemsFunction(checkoutId, lineItemIds) { try { const updatedCheckout = await checkout.removeLineItems( checkoutId, lineItemIds, ); console.log("Success! Line items removed from checkout:", updatedCheckout); return updatedCheckout; } catch (error) { console.error(error); // Handle the error } } /************* * Page code * ************/ import { myRemoveLineItemsFunction } from "backend/my-backend-file"; // Sample checkoutId: const checkoutId = "23a7b29a-3c14-4ef1-9353-f4b714b13217"; // Sample line item IDs const lineItemIds = [ "00000000-0000-0000-0000-000000000002", "00000000-0000-0000-0000-000000000003", ]; myRemoveLineItemsFunction(checkoutId, lineItemIds) .then((updatedCheckout) => { const checkoutId = updatedCheckout._id; const numOfLineItems = updatedCheckout.lineItems.length; console.log("Success! Line items removed from checkout:", updatedCheckout); return updatedCheckout; }) .catch((error) => { console.error(error); // Handle the error }); /* Promise resolves to: * * * { * "_id": "23a7b29a-3c14-4ef1-9353-f4b714b13217", * "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://example.wixsite.com", * "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": "20", * "convertedAmount": "20", * "formattedAmount": "$20.00", * "formattedConvertedAmount": "$20.00" * }, * "totalPriceBeforeTax": { * "amount": "20", * "convertedAmount": "20", * "formattedAmount": "$20.00", * "formattedConvertedAmount": "$20.00" * }, * "taxDetails": { * "taxableAmount": { * "amount": "20", * "convertedAmount": "20", * "formattedAmount": "$20.00", * "formattedConvertedAmount": "$20.00" * }, * "taxRate": "0", * "totalTax": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "rateBreakdown": [] * }, * "discount": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.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" * } * ], * "billingInfo": { * "address": { * "addressLine1": "235 West 23rd Street", * "addressLine2": "3rd floor", * "city": "New York", * "subdivision": "US-NY", * "country": "US", * "postalCode": "10011" * }, * "contactDetails": { * "firstName": "Jane", * "lastName": "Doe", * "phone": "+1234567890" * } * }, * "shippingInfo": { * "shippingDestination": { * "address": { * "addressLine1": "235 West 23rd Street", * "addressLine2": "3rd floor", * "city": "New York", * "subdivision": "US-NY", * "country": "US", * "postalCode": "10011" * }, * "contactDetails": { * "firstName": "Jane", * "lastName": "Doe", * "phone": "+1234567890" * } * }, * "selectedCarrierServiceOption": { * "code": "ed5bbce2-9533-dff4-7db0-13702fd139c5", * "title": "Standard US Shipping", * "logistics": { * "deliveryTime": "" * }, * "cost": { * "totalPriceAfterTax": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "totalPriceBeforeTax": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "taxDetails": { * "taxRate": "0", * "totalTax": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "rateBreakdown": [] * }, * "price": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * } * }, * "requestedShippingOption": true, * "otherCharges": [], * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc" * }, * "region": { * "_id": "009fbe5d-89d3-7825-cbbf-1aab4d908b73", * "name": "USA shipping" * }, * "carrierServiceOptions": [ * { * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc", * "shippingOptions": [ * { * "code": "ed5bbce2-9533-dff4-7db0-13702fd139c5", * "title": "Standard US Shipping", * "logistics": { * "deliveryTime": "" * }, * "cost": { * "price": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "otherCharges": [] * } * } * ] * } * ] * }, * "buyerNote": "Please wrap it up as a present", * "buyerInfo": { * "contactId": "f7dc17a6-825a-466e-a78e-c4abea0217db", * "email": "Janedoe@example.com", * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873" * }, * "conversionCurrency": "USD", * "priceSummary": { * "subtotal": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "shipping": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "tax": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "discount": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.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", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "name": "SUMMERSALE10", * "couponType": "MoneyOff" * } * } * ], * "customFields": [ * { * "value": "12345", * "title": "Tax ID", * "translatedTitle": "Tax ID" * } * ], * "weightUnit": "KG", * "currency": "USD", * "channelType": "WEB", * "siteLanguage": "en", * "buyerLanguage": "en", * "completed": false, * "taxIncludedInPrice": false, * "createdBy": { * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873" * }, * "_createdDate": "2022-10-26T10:55:56.759Z", * "_updatedDate": "2022-10-26T10:56:59.653Z", * "payNow": { * "subtotal": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "shipping": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "tax": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "discount": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.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": [] * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

removeOverrideCheckoutUrl( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Removes the overrideCheckoutUrl from a specified checkout.

When overrideCheckoutUrl is removed, the checkoutUrl will be set to the default, standard Wix checkout page URL.

Permissions
Manage eCommerce - all permissions
Manage Stores - all permissions
Manage Orders
Manage Restaurants - all permissions
Learn more about app permissions.
Method Declaration
Copy
function removeOverrideCheckoutUrl(
  _id: string,
): Promise<RemoveOverrideCheckoutUrlResponse>;
Method Parameters
_idstringRequired

ID of the checkout to remove the override checkout url from.

Returns
Return Type:Promise<RemoveOverrideCheckoutUrlResponse>
JavaScript
import { checkout } from "wix-ecom-backend"; async function removeOverrideCheckoutUrl(id) { try { const result = await checkout.removeOverrideCheckoutUrl(id); return result; } catch (error) { console.error(error); // Handle the error } }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

updateCheckout( )


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.
Permissions
Manage eCommerce - all permissions
Manage Stores - all permissions
Manage Orders
Manage Restaurants - all permissions
Manage eCommerce - Admin Permissions
Learn more about app permissions.
Method Declaration
Copy
function updateCheckout(
  _id: string,
  checkout: UpdateCheckout,
  options: UpdateCheckoutOptions,
): Promise<Checkout>;
Method Parameters
_idstringRequired

Checkout ID.


checkoutUpdateCheckoutRequired

optionsUpdateCheckoutOptions

Checkout update options.

Returns
Return Type:Promise<Checkout>

Updates the buyerNote and adds a coupon to the 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" * } * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

updateLineItemsQuantity( )


Updates the quantity of one or more line items in a checkout.

This endpoint is only for updating the quantity of line items. To entirely remove a line item from the checkout, use removeLineItems(). To add a new line item to the checkout, use addToCheckout().

This endpoint checks the amount of stock remaining for this line item. If the specified quantity is greater than the remaining stock, then the quantity returned in the response is the total amount of remaining stock.

Permissions
Manage eCommerce - all permissions
Manage Stores - all permissions
Manage Orders
Manage Restaurants - all permissions
Learn more about app permissions.
Method Declaration
Copy
function updateLineItemsQuantity(
  _id: string,
  lineItems: Array<LineItemQuantityUpdate>,
): Promise<UpdateLineItemsQuantityResponse>;
Method Parameters
_idstringRequired

Checkout ID.


lineItemsArray<LineItemQuantityUpdate>Required

Line item info to update.

Returns
Return Type:Promise<UpdateLineItemsQuantityResponse>
JavaScript
import { checkout } from "wix-ecom-backend"; /* Sample checkoutId value: '21fe558e-21a0-4cff-a49b-a4ccb0f7414d' * * Sample listItems value: * { * _id: '00000000-0000-0000-0000-000000000001', * quantity: 10 * } */ export async function myUpdateQuantityFunction(checkoutId, lineItems) { try { const updatedCheckout = await checkout.updateLineItemsQuantity( checkoutId, lineItems, ); const firstUpdatedLineItem = updatedCheckout.checkout.lineItems[0]; const updatedQuantity = firstUpdatedLineItem.quantity; console.log( "Success! The updated quantity for the first line item is:", updatedQuantity, ); return updatedCheckout; } catch (error) { console.error(error); } } /* Promise resolves to: * { * "checkout": { * "_id": "21fe558e-21a0-4cff-a49b-a4ccb0f7414d", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000001", * "quantity": 10, * "catalogReference": { * "catalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e" * }, * "productName": { * "original": "Shirt", * "translated": "Shirt" * }, * "url": "https://example.wixsite.com/product-page/shirt", * "price": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "lineItemPrice": { * "amount": "100", * "convertedAmount": "100", * "formattedAmount": "$100.00", * "formattedConvertedAmount": "$100.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": "100", * "convertedAmount": "100", * "formattedAmount": "$100.00", * "formattedConvertedAmount": "$100.00" * }, * "totalPriceBeforeTax": { * "amount": "100", * "convertedAmount": "100", * "formattedAmount": "$100.00", * "formattedConvertedAmount": "$100.00" * }, * "taxDetails": { * "taxableAmount": { * "amount": "100", * "convertedAmount": "100", * "formattedAmount": "$100.00", * "formattedConvertedAmount": "$100.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/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": "Updated note.", * "buyerInfo": { * "contactId": "a4bc8d90-a91b-467f-a775-77d65dd0442e", * "email": "testing3@example.com", * "memberId": "ea3d74df-b7dc-4ca1-a7c9-c416b9017a86" * }, * "conversionCurrency": "USD", * "priceSummary": { * "subtotal": { * "amount": "100", * "convertedAmount": "100", * "formattedAmount": "$100.00", * "formattedConvertedAmount": "$100.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": "100", * "convertedAmount": "100", * "formattedAmount": "$100.00", * "formattedConvertedAmount": "$100.00" * }, * "additionalFees": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * } * }, * "calculationErrors": { * "orderValidationErrors": [] * }, * "appliedDiscounts": [], * "customFields": [], * "weightUnit": "LB", * "currency": "USD", * "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-04-30T05:51:13.309Z", * "payNow": { * "subtotal": { * "amount": "100", * "convertedAmount": "100", * "formattedAmount": "$100.00", * "formattedConvertedAmount": "$100.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": "100", * "convertedAmount": "100", * "formattedAmount": "$100.00", * "formattedConvertedAmount": "$100.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": "100", * "convertedAmount": "100", * "formattedAmount": "$100.00", * "formattedConvertedAmount": "$100.00" * } * } * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?