Ecwid.Cart.removeProduct

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

NameTypeDescription
indexintegerIndex of a product to remove. Starts with 0.
callbackfunctionCallback 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

NameTypeDescription
successBooleantrue 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.
errorStringError message. Available only if success is false.