Skip to main content

Type Alias: RemoveCartItem

RemoveCartItem = (cartId, cartItemId) => Promise<void>

Function

Removes a specific item from the cart.

This method deletes a single item from the cart based on its unique identifier. It's equivalent to taking a product out of your shopping basket before checkout, and provides immediate feedback to reflect the updated cart state.

Business value:

  • Gives customers control to refine their selections before purchase
  • Immediately updates pricing totals to reflect removed items
  • Supports dynamic cart management in custom interfaces
  • Helps prevent order errors by allowing easy removal of unwanted items

Parameters​

cartId​

string

The unique identifier for the cart

cartItemId​

string

The unique identifier for the specific item to remove

Returns​

Promise<void>

A promise that resolves when the item has been successfully removed

Example​

// Remove an item when the user clicks a "Remove" button
document.querySelector('.remove-item-btn').addEventListener('click', async (e) => {
const cartId = e.target.dataset.cartId;
const itemId = e.target.dataset.itemId;

try {
await window.mimeeqApp.actions.removeCartItem(cartId, itemId);
// Remove the item from the UI
document.getElementById(`cart-item-${itemId}`).remove();
// Update cart totals
updateCartTotals();
} catch (error) {
showErrorMessage('Could not remove item from cart');
}
});

Throws​

Will throw an error if the cart or item ID is missing or if removal fails

Emits​

mimeeq-basket-updated When the item is successfully removed, providing updated cart state