# Programmatically remove item(s) from cart if a logic returns false

**URL:** <https://forum.shopware.com/t/programmatically-remove-item-s-from-cart-if-a-logic-returns-false/90374>\
**Category:** Shopware 6 (English)\
**Tags:** programming\
**Created:** [16. September 2021 um 15:06 UTC](https://forum.shopware.com/t/programmatically-remove-item-s-from-cart-if-a-logic-returns-false/90374 "2021-09-16T15:06:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anitchec.dev](https://avatars.discourse-cdn.com/v4/letter/a/cc9497/32.png) [@anitchec.dev](https://forum.shopware.com/u/anitchec.dev)\
**Post date:** [16. September 2021 um 15:06 UTC](https://forum.shopware.com/t/programmatically-remove-item-s-from-cart-if-a-logic-returns-false/90374/1 "2021-09-16T15:06:58Z")

</div>

I would like to hook into an event fired when an item is added to cart (Not sure which one), and if a set of logic fails in the event subscriber, then i would like to remove said item from cart.

---

<div class="post-metadata">

**Author:** ![moschadr](https://avatars.discourse-cdn.com/v4/letter/m/65b543/32.png) [@moschadr](https://forum.shopware.com/u/moschadr)\
**Post date:** [13. Oktober 2021 um 14:52 UTC](https://forum.shopware.com/t/programmatically-remove-item-s-from-cart-if-a-logic-returns-false/90374/2 "2021-10-13T14:52:36Z")

</div>

a subscriber (implements EventSubscriberInterface) in YourPlugin/src/Storefron/Page/… would be your „friend“
