Get cart details

Find out more about cart in its current state.

Order Object

Get order total example

Ecwid.Cart.calculateTotal(function(order) {

// prints
// 13.25

Order object represents details of current customer’s order.

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


cart<Cart>The object describing the state or customer’s cart
couponDiscountintegerAn absolute amount of coupon code discount for this order
customerGroupDiscountintegerAn absolute amount of a discount based on customer group for this order
customerGroupVolumeDiscountintegerAn absolute amount of a discount based on customer group and subtotal for this order
discountintegerAn absolute amount of a total discount for this order
handlingFeeintegerAn absolute amount of handling fee applied to order
shippingintegerAn absolute amount of shipping rate applied to order
taxintegerAn absolute amount of tax rate applied to order
totalintegerTotal amount of this order
volumeDiscountintegerAn absolute amount of a discount based on subtotal for this order

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.

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

Get full cart details


Get quantity of products in cart example

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

// prints
// Products in cart now: 1


itemsArray<CartItem>Enlists all items currently present in customer’s cart
productsQuantityintegerTotal number of product varieties in cart
orderIdintegerUnique internal order ID for this order (available after order is created)
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.
weightnumberTotal weight of the
shippingMethodstringThe name of the selected shipping method (if any)
cartIdstringCart ID you can use later in the cart endpoint of Ecwid REST API
shippingPerson<Person>Customer’s shipping address

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 provice code
phonestringCustomer’s phone number

CartItem Object

CartItem represents a single item (product variety) in cart.

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

Get quantity of a product in cart example

Ecwid.OnCartChanged.add(function(cart) {
  console.log("There are " + cart.items[0].quantity + " items of " + cart.items[0] + " in cart now.");

// prints
// There are 1 items of Apple product in cart now.


quantityintegerQuantity of the given product variety in cart
productArray<Product>The map of product properties (variation properties, if the variation is added to cart)
optionsObject with option names and valuesMap of the product options (option name as a key and option value as a value). For listboxes and radio buttons value will be the string value of the selected option. For checkboxes — names of the selected options, comma separated. For date options — string representing the selected date according to the shop’s format (Ecwid control panel > System settings > General > Formats and Units). For textboxes и textareas — the text given by the customer. For file upload options — string in the form of „4 files”

Product Object

Product object represents details of a specific product in cart.

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

Get product name and SKU in cart example

Ecwid.OnCartChanged.add(function(cart) {
  console.log(cart.items[0] + " in the cart has SKU: " + cart.items[0].product.sku);

// prints
// Apple product in the cart has SKU: TEST-1234


idintegerInternal unique product ID
nameitringProduct name
priceintegerProduct price
shortDescriptionstringProduct description truncated to 120 characters
skustringProduct SKU
urlstringURL to this product details page in store front (store front URL is generated from a field in Ecwid Control panel > Settings > General > Store profile)
weightintegerWeight of a product

We use cookies and similar technologies to remember your preferences, measure effectiveness of our campaigns, and analyze depersonalized data to improve performance of our site. By choosing «Accept», you consent to the use of cookies.