Cart Object

Cart object is a snapshot of essential shopping cart properties, passed via various callbacks. Cart object does not provide direct memory access to the actual cart that Ecwid uses — i.e. changing this exact object will not alter the actual cart Ecwid uses for placing the order.

This function allows to get information about current customer's cart and pass the result as a cart object.

Subscribe to the Ecwid.OnAPILoaded JS API event to ensure availability of this function.

Ecwid.Cart.get(function(cart) {
  console.log("Products in cart now: " + cart.productsQuantity);

// prints
// Products in cart now: 1


cartIdstringCart ID you can use later in the cart endpoint of Ecwid REST API
idstringUnique order ID, it remains the same when order is placed
couponNamestringThe name of the coupon (if any) applied to the cart. If no coupon was applied, will contain undefined. Does not contain the actual code of coupon, just the name.
itemsArray<CartItem>Enlists all items currently present in customer’s cart
orderIdintegerInternal order ID
productsQuantityintegerTotal number of product varieties in cart
shippingMethodstringThe name of the selected shipping method (if any)
shippingPerson<Person>Customer's shipping address
weightnumberTotal weight of the

Person fields:

namestringCustomer's name
companyNamestringCustomer's company name
streetstringCustomer's street address. Use \n to place text in Address Line 2
citystringCustomer's city
countryNamestringCustomer's country name. countryCode can be used instead
countryCodestringCustomer's country code. countryName can be used instead
postalCodestringCustomer's zip code
stateOrProvinceCodestringCustomer's state or province code
phonestringCustomer's phone number