Cart v1
Events
Listen for the cart being mounted or changed.
You're reading the docs for cart v1, the version in production. Cart v2 is in beta.
Cart mounted
Listening to the cart mounted event can be made by listening to the circuly-cart-mounted event.
const onMounted = (event) => {
console.debug("Cart mounted!")
//
}
window.addEventListener("circuly-cart-mounted", onMounted);
Cart changed
Listening to cart state changes can be made by listening to the circuly-cart-changed event.
const onChanged = (event) => {
console.debug("Cart changed!", event.detail)
//
}
window.addEventListener("circuly-cart-changed", onChanged);
Cart interface structure
interface CartItem {
id: number;
sku: string;
name: string;
children: object[];
}
interface Cart {
cart_id: string;
items: CartItem[];
}