Setup

To use the CurrentCart 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 { currentCart } from @wix/ecom:

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

addToCurrentCart( )

Adds catalog line items to the current site visitor's cart.

The addToCurrentCart() function returns a Promise that resolves to the updated current 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 addToCurrentCart(options: AddToCurrentCartOptions): Promise<AddToCartResponse>
Method Parameters
optionsAddToCurrentCartOptions

Items to be added to the current cart.

Returns
Return Type:Promise<AddToCartResponse>
Was this helpful?
Yes
No

createCheckoutFromCurrentCart( )

Creates a checkout from the current site visitor’s cart.

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

If a checkout was already created from the current 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 createCheckoutFromCurrentCart(options: CreateCheckoutFromCurrentCartOptions): Promise<CreateCheckoutResponse>
Method Parameters
optionsCreateCheckoutFromCurrentCartOptions

Checkout creation options.

Returns
Return Type:Promise<CreateCheckoutResponse>
Was this helpful?
Yes
No

deleteCurrentCart( )

Deletes the current site visitor's cart.

The deleteCurrentCart() function returns a Promise that resolves when the current 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 deleteCurrentCart(): Promise<void>
Request
This method does not take any parameters
Was this helpful?
Yes
No

estimateCurrentCartTotals( )

Estimates the current cart's price totals (including tax), based on a selected carrier service, shipping address, and billing information.

The estimateCurrentCartTotals() 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 estimateCurrentCartTotals(options: EstimateCurrentCartTotalsOptions): Promise<EstimateTotalsResponse>
Method Parameters
optionsEstimateCurrentCartTotalsOptions

Total estimation options.

Returns
Return Type:Promise<EstimateTotalsResponse>
Was this helpful?
Yes
No

getCurrentCart( )

Retrieves the current site visitor's cart.

The getCurrentCart() function returns a Promise that resolves when the current 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 getCurrentCart(): Promise<Cart>
Request
This method does not take any parameters
Returns
Return Type:Promise<Cart>
Was this helpful?
Yes
No

removeCouponFromCurrentCart( )

Removes the coupon from the current site visitor's cart.

The removeCouponFromCurrentCart() function returns a Promise that resolves to the updated current cart when the coupon is removed.

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 removeCouponFromCurrentCart(): Promise<RemoveCouponResponse>
Request
This method does not take any parameters
Returns
Return Type:Promise<RemoveCouponResponse>
Was this helpful?
Yes
No

removeLineItemsFromCurrentCart( )

Removes line items from the current site visitor's cart.

The removeLineItemsFromCurrentCart() function returns a Promise that resolves to the updated current cart when the line items are removed.

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 removeLineItemsFromCurrentCart(lineItemIds: Array<string>): Promise<RemoveLineItemsResponse>
Method Parameters
lineItemIdsArray<string>Required

IDs of the line items to remove from the cart.

Returns
Return Type:Promise<RemoveLineItemsResponse>
Was this helpful?
Yes
No

updateCurrentCart( )

Updates the current site visitor's cart.

The updateCurrentCart() function returns a Promise that resolves when the current 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 updateCurrentCart(options: UpdateCurrentCartOptions): Promise<Cart>
Method Parameters
optionsUpdateCurrentCartOptions

Current cart update options.

Returns
Return Type:Promise<Cart>
Was this helpful?
Yes
No

updateCurrentCartLineItemQuantity( )

Updates the quantity of one or more line items in the current site visitor's cart.

The updateCurrentCartLineItemQuantity() function returns a Promise that resolves when the quantities of the current 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 current cart, use removeLineItemsFromCurrentCart(). To add a new line item to the current cart, use addToCurrentCart().

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 updateCurrentCartLineItemQuantity(lineItems: Array<LineItemQuantityUpdate>): Promise<UpdateLineItemsQuantityResponse>
Method Parameters
lineItemsArray<LineItemQuantityUpdate>Required

Line item IDs and their new quantity.

Returns
Return Type:Promise<UpdateLineItemsQuantityResponse>
Was this helpful?
Yes
No