Setup

To use the Cart API, install the @wix/ecom package using npm or Yarn:

Copy
1
npm install @wix/ecom

or

Copy
1
yarn add @wix/ecom

Then import { cart } from @wix/ecom:

Copy
1
import { cart } from '@wix/ecom'
Was this helpful?
Yes
No

addToCart( )

Adds catalog line items to a cart.

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

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

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Stores - all permissions
Manage eCommerce - all permissions
Learn more about permission scopes.
Copy
function addToCart(_id: string, options: AddToCartOptions): Promise<AddToCartResponse>
Method Parameters
_idstringRequired
Cart ID.

optionsAddToCartOptions
Items to be added to cart.
Returns
Return Type:Promise<AddToCartResponse>
Was this helpful?
Yes
No

createCart( )

Creates a new cart.

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

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

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Stores - all permissions
Manage eCommerce - all permissions
Learn more about permission scopes.
Copy
function createCart(options: CreateCartOptions): Promise<Cart>
Method Parameters
optionsCreateCartOptions
Cart creation options.
Returns
Return Type:Promise<Cart>
Was this helpful?
Yes
No

createCheckout( )

Creates a checkout from a cart.

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

If a checkout was already created from the specified cart, that checkout will be updated with any new information from the cart.

Note: options.channelType is a required field.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Stores - all permissions
Manage eCommerce - all permissions
Manage Orders
Learn more about permission scopes.
Copy
function createCheckout(_id: string, options: CreateCheckoutOptions): Promise<CreateCheckoutResponse>
Method Parameters
_idstringRequired
Cart ID.

optionsCreateCheckoutOptions
Checkout creation options.
Returns
Return Type:Promise<CreateCheckoutResponse>
Was this helpful?
Yes
No

deleteCart( )

Deletes a cart.

The deleteCart() function returns a Promise that resolves when the specified cart is deleted.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Stores - all permissions
Manage eCommerce - all permissions
Learn more about permission scopes.
Copy
function deleteCart(_id: string): Promise<void>
Method Parameters
_idstringRequired
ID of the cart to delete.
Returns
Return Type:Promise<void>
Was this helpful?
Yes
No

estimateTotals( )

Estimates the subtotal and total for current site visitor’s cart. Totals include tax and are based on the selected carrier service, shipping address, and billing information.

The estimateTotals() function returns a Promise that resolves when the estimated totals are generated.

Note: Not passing any options properties will only estimate the cart items price totals.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Stores - all permissions
Read eCommerce - all read permissions
Read Orders
Read Stores - all read permissions
Manage eCommerce - all permissions
Manage Orders
Learn more about permission scopes.
Copy
function estimateTotals(_id: string, options: EstimateTotalsOptions): Promise<EstimateTotalsResponse>
Method Parameters
_idstringRequired
Cart ID.

optionsEstimateTotalsOptions
Total estimation options.
Returns
Return Type:Promise<EstimateTotalsResponse>
Was this helpful?
Yes
No

getCart( )

Retrieves a cart.

The getCart() function returns a Promise that resolves when the specified cart is retrieved.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Stores - all permissions
Read eCommerce - all read permissions
Read Orders
Read Stores - all read permissions
Manage eCommerce - all permissions
Manage Orders
Learn more about permission scopes.
Copy
function getCart(_id: string): Promise<Cart>
Method Parameters
_idstringRequired
ID of the cart to retrieve.
Returns
Return Type:Promise<Cart>
Was this helpful?
Yes
No

removeCoupon( )

Removes the coupon from a specified cart.

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

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Stores - all permissions
Manage eCommerce - all permissions
Learn more about permission scopes.
Copy
function removeCoupon(_id: string): Promise<RemoveCouponResponse>
Method Parameters
_idstringRequired
Cart ID.
Returns
Return Type:Promise<RemoveCouponResponse>
Was this helpful?
Yes
No

removeLineItems( )

Removes line items from the specified cart.

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

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Stores - all permissions
Manage eCommerce - all permissions
Learn more about permission scopes.
Copy
function removeLineItems(_id: string, lineItemIds: Array<string>): Promise<RemoveLineItemsResponse>
Method Parameters
_idstringRequired
ID of the cart to remove line items from.

lineItemIdsArray<string>Required
IDs of the line items to remove from the cart.
Returns
Return Type:Promise<RemoveLineItemsResponse>
Was this helpful?
Yes
No

updateCart( )

Updates a specified cart's properties.

The updateCart() function returns a Promise that resolves when the specified cart's properties are updated.

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

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Stores - all permissions
Manage eCommerce - all permissions
Learn more about permission scopes.
Copy
function updateCart(_id: string, options: UpdateCartOptions): Promise<Cart>
Method Parameters
_idstringRequired
ID of the cart to be updated.

optionsUpdateCartOptions
Available options to use when updating a cart.
Returns
Return Type:Promise<Cart>
Was this helpful?
Yes
No

updateLineItemsQuantity( )

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

The updateLineItemsQuantity() function returns a Promise that resolves when the quantities of the specified cart's line items are updated.

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

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.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Stores - all permissions
Manage eCommerce - all permissions
Learn more about permission scopes.
Copy
function updateLineItemsQuantity(_id: string, lineItems: Array<LineItemQuantityUpdate>): Promise<UpdateLineItemsQuantityResponse>
Method Parameters
_idstringRequired
Cart ID.

lineItemsArray<LineItemQuantityUpdate>Required
Line item IDs and their new quantity.
Returns
Return Type:Promise<UpdateLineItemsQuantityResponse>
Was this helpful?
Yes
No