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(cart);
});
Ecwid.Cart.get(function(cart) {
console.log("Products in cart now: " + cart.productsQuantity);
});
// prints
// Products in cart now: 1
Fields:
Name | Type | Description |
---|---|---|
cartId | string | Cart ID you can use later in the cart endpoint of Ecwid REST API |
id | string | Unique order ID, it remains the same when order is placed |
couponName | string | The 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. |
items | Array<CartItem> | Enlists all items currently present in customer’s cart |
orderId | integer | Internal order ID |
productsQuantity | integer | Total number of product varieties in cart |
shippingMethod | string | The name of the selected shipping method (if any) |
shippingPerson | <Person> | Customer's shipping address |
weight | number | Total weight of the items in cart |
Person fields:
Name | Type | Description |
---|---|---|
name | string | Customer's name |
companyName | string | Customer's company name |
street | string | Customer's street address. Use \n to place text in Address Line 2 |
city | string | Customer's city |
countryName | string | Customer's country name. countryCode can be used instead |
countryCode | string | Customer's country code. countryName can be used instead |
postalCode | string | Customer's zip code |
stateOrProvinceCode | string | Customer's state or province code |
phone | string | Customer's phone number |