How to remove item line from the cart using removeLine(line) Function

Description : Removes a line from the cart. To decrease (or increase) the line quantity, use updateLine() instead. To remove lines from the cart.

var cart = container.getComponent("Cart");

var lines = cart.getLines();
var removed = 0;

lines.then(function(lines, removed) {
	for (i=0; i < lines.length; i++) {
		cart.removeLine({
			line_id: lines[i].internalid
		}).then(function() {
			removed++;
		});
	}
}).then(function(removed) {
	if (removed == lines.length) {
		console.log("All lines removed successfully");
	}
	else {
		alert("Some lines could not be removed.");
	}
});

Leave a comment

Your email address will not be published. Required fields are marked *