LogoLogo
Build appsContact API support
Storefronts
  • Build apps
  • Site Templates
  • API Reference
  • Changelog
Storefronts
  • Ecwid storefronts overview
  • Get started
    • Storefront customization options
    • Quickstart: customize storefront with Ecwid JS API
  • Track Storefront events
    • "Page is loaded" events
    • "Customer logged in" event
    • "Cart details are changed" event
    • "New order is placed" event
    • "Instant Site section load" events
  • Get Storefront details
    • Get Ecwid store ID
    • Get storefront language and currency
    • Get visitor location
    • Get public app details
  • Manage customers on the storefront
    • Get logged in customer's details
    • Manage customer's cookie consent
    • Log out customer
  • Open page on the storefront
    • Overview of open page options
    • Open product pages with params
    • Open category pages with params
    • Open search page with params
    • Open account pages with params
  • Manage cart and checkout
    • Get cart details
    • Add product to the cart
    • Remove product from the cart
    • Fully clear the cart
    • Create pre-filled shopping carts
    • Calculate cart details
    • Send customer to the checkout
    • Set customer's email for the checkout
    • Set customer's comments for order
    • Set customer's shipping and billing addresses
    • Set custom order referer
  • Store configuration settings
    • Overview
    • Behavioral configs
    • Design configs

Lightspeed® 2025

On this page

Was this helpful?

  1. Track Storefront events

"Cart details are changed" event

Last updated 2 months ago

Was this helpful?

Ecwid.OnCartChanged

This event allows tracking any cart changes excluding the payment method selection. Its callback function with the cart contains details about the cart after the change event.

Ecwid.OnCartChanged event triggers when:

  • Cart is initialized, synced, or cleared.

  • Product has been added, updated (increased quantity, changed selected options), or removed from the cart.

  • Discount coupon or discount is applied or removed.

  • Shipping address is added or updated.

  • Shipping method is selected or changed.

Code example:

Ecwid.OnCartChanged.add(function(cart){
    console.log(JSON.stringify(cart));
});

// prints
// 
// {
// 	"id":"TJ6VG",
// 	"cartId":"99E7E224-5F6F-4C00-BFE9-9F72F2B5A471",
// 	"orderId":506524300,
// 	"items":[...],
// 	"productsQuantity":4,
// 	"shippingMethod":"Standard shipping",
// 	"shippingPerson":{...},
// 	"weight":4
// }

cart argument fields

Field
Type
Description

cartId

string

Cart ID. Matches with the cart ID in REST API /carts endpoint.

id

string

Order ID, assigned to the cart. Remains the same when an order is placed.

couponName

string

Name of the discount coupon applied to the cart. Does not contain the actual coupon code.

items

array{object}

Details about products in the shopping cart.

orderId

number

Internal order ID.

productsQuantity

number

Total quantity of products added to the shopping cart.

weight

number

Total weight of products added to the shopping cart.

shippingMethod

string

Name of the selected shipping method. Available only when a customer goes to the checkout_payment_details page.

shippingPerson

object{shippingPerson}

Details about shipping address. Available only when a customer goes to the shipping_delivery page.

items

items contains an array of objects with the details for each product added to the shopping cart.

Field
Type
Description

quantity

number

Quantity of the specific product added to the shopping cart.

product

object product

Details about the product added to the shopping cart.

options

object

Map of the selected product options (option name as a key and option value as a value).

Code example for options object:

"options": {  
    "Size": "M",  
    "Print_number": "9"  
}

product

Field
Type
Description

id

number

Internal product ID.

sku

string

Product SKU.

price

number

Product price before applied taxes, fees, or discounts.

name

string

Product name.

weight

number

Product weight.

shortDescription

string

Product description truncated to 120 characters.

url

string

Link to the product page.

variation

number

Product variation ID.

shippingPerson

Name
Type
Description

name

string

Customer's name.

companyName

string, optional

Company name of a customer, if available.

street

string, optional

Shipping/billing address. Street.

city

string, optional

Shipping/billing address. City.

countryName

string, optional

Shipping/billing address. Country name.

countryCode

string, optional

Shipping/billing address. Country code in ISO 3166-2.

postalCode

string, optional

Shipping/billing address. ZIP code.

stateOrProvinceCode

string, optional

Shipping/billing address. State code ISO 3166-2.

phone

string, optional

Customer's phone number, if available.

argument