I have a controller that loops through all items in the cart, and removes the item if it matches the condition, in this case all products should be removed because of the true as condition.

$cart = Mage::helper('checkout/cart')->getCart();

// Loop through products
foreach ($cart->getItems() as $item) {
  if(true) { // Normally a different condition

The script does remove all items, except for those added as promotional item by a module (Amasty Free Gifts / Promo Items). The items unique key doesn't change, so it is not being removed from the cart, neither added again by the module, because the key hasn't changed.

When I delete the main item, the promo item came with, the promo item is deleted.

How can I delete this product?

1 Answer 1



$cartHelper = Mage::helper('checkout/cart');
$items = $cartHelper->getCart()->getItems();
foreach ($items as $item) {
    if ($item->getProduct()->getSku() == 'promo') {
  • The removeItem() function isn't reached, there are no items with sku 'promo'. Jul 9, 2018 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.