Removes a product from a customer's cart by its index.
Request example:
// returns cart details with items array. Use it to get the index
Ecwid.Cart.get(function(cart){
console.log(cart);
})
// remove first product from customer's cart
Ecwid.Cart.removeProduct(0);
Ecwid.Cart.removeProduct(index,callback)
receives one argument: index
Name | Type | Description |
---|---|---|
index | integer | Index of a product to remove. Starts with 0. |
callback | function | Callback function to be called once the operation is complete (either succeeded or failed). See below for details. |
Callback function
Removing products from the cart is an async function, so if you need automation depending on the result, use the callback function. Callback receives 4 arguments: success, product, cart, error
Name | Type | Description |
---|---|---|
success | Boolean | true if product was removed, false otherwise. |
product | <Product> | Product object removed from the cart. Available only if success is true . |
cart | <Cart> | Cart object after removing a product. |
error | String | Error message. Available only if success is false . |