# How to properly remove a product from the cart with JavaScript

URL: https://shoptet.dev/news/frontend/how-to-properly-remove-a-product-from-the-cart-with-javascript

August 4, 2021 · One min read
Pavel Husa

In the past, we introduced the JS function `addToCart` that can be used to add various items to the cart see a post [here](/templates/add-to-cart-javascript/) .
As a complementary function we added function to remove an item from the cart available in Shoptet structure: `shoptet.cartShared.removeFromCart` . This function accepts one parameter `itemId` formed as an object. This ID can be found in a cart form as hidden input element.

![](/assets/images/screenshot-2021-08-04-at-09.25.33-300x154-8b4651038e6a7948f16c0294e227dc92.png)

The following examples use product and parameter ids from [https://classic.shoptet.cz/](https://classic.shoptet.cz/) .

```javascript
/* Add product */
shoptet.cartShared.addToCart({priceId: 1745});
/* Remove added product */
shoptet.cartShared.removeFromCart({itemId: '610a403f6a8fa'});
```

Please note that the function removes an item even if an amount is greater than one.

**Tags:**
- [Frontend](/news/tags/frontend/)
