Setup
To use the Cart API, install the @wix/ecom
package using npm or Yarn:
1npm install @wix/ecom
or
1yarn add @wix/ecom
Then import { cart }
from @wix/ecom
:
1import { cart } from '@wix/ecom'
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:function addToCart(_id: string, options: AddToCartOptions): Promise<AddToCartResponse>
Cart ID.
Items to be added to cart.
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:function createCart(options: CreateCartOptions): Promise<Cart>
Cart creation options.
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:function createCheckout(_id: string, options: CreateCheckoutOptions): Promise<CreateCheckoutResponse>
Cart ID.
Checkout creation options.
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:function deleteCart(_id: string): Promise<void>
ID of the cart to delete.
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:function estimateTotals(_id: string, options: EstimateTotalsOptions): Promise<EstimateTotalsResponse>
Cart ID.
Total estimation options.
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:function getCart(_id: string): Promise<Cart>
ID of the cart to retrieve.
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:function removeCoupon(_id: string): Promise<RemoveCouponResponse>
Cart ID.
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:function removeLineItems(_id: string, lineItemIds: Array<string>): Promise<RemoveLineItemsResponse>
ID of the cart to remove line items from.
IDs of the line items to remove from the cart.
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:function updateCart(_id: string, options: UpdateCartOptions): Promise<Cart>
ID of the cart to be updated.
Available options to use when updating a cart.
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:function updateLineItemsQuantity(_id: string, lineItems: Array<LineItemQuantityUpdate>): Promise<UpdateLineItemsQuantityResponse>
Cart ID.
Line item IDs and their new quantity.