Setup
To use the CurrentCart API, install the @wix/ecom
package using npm or Yarn:
1npm install @wix/ecom
or
1yarn add @wix/ecom
Then import { currentCart }
from @wix/ecom
:
1import { currentCart } from '@wix/ecom'
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:function addToCurrentCart(options: AddToCurrentCartOptions): Promise<AddToCartResponse>
Items to be added to the current cart.
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:function createCheckoutFromCurrentCart(options: CreateCheckoutFromCurrentCartOptions): Promise<CreateCheckoutResponse>
Checkout creation options.
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:function deleteCurrentCart(): Promise<void>
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:function estimateCurrentCartTotals(options: EstimateCurrentCartTotalsOptions): Promise<EstimateTotalsResponse>
Total estimation options.
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:function getCurrentCart(): Promise<Cart>
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:function removeCouponFromCurrentCart(): Promise<RemoveCouponResponse>
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:function removeLineItemsFromCurrentCart(lineItemIds: Array<string>): Promise<RemoveLineItemsResponse>
IDs of the line items to remove from the cart.
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:function updateCurrentCart(options: UpdateCurrentCartOptions): Promise<Cart>
Current cart update options.
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:function updateCurrentCartLineItemQuantity(lineItems: Array<LineItemQuantityUpdate>): Promise<UpdateLineItemsQuantityResponse>
Line item IDs and their new quantity.