How can I remove all items from cart in JS SDK

I don’t seem to find an easy way to remove all items from cart in JS SDK. Can you share JS code to do that?

Hi @keithlei01

You could use something like this:

Snipcart.store.getState().cart.items.items.forEach(
    (el) => Snipcart.api.cart.items.remove(el.uniqueId)
);

Is that what you need?

Thanks.

1 Like