Skip to main content
Bumped by Community user
edited tags
Link
7ochem
  • 7.6k
  • 14
  • 52
  • 80
Source Link
Venelin Vasilev
  • 1.1k
  • 4
  • 33
  • 60

How to clear a specific user cart items without session

Here is how the cart is cleared for the current session user:

$cart = Mage::getSingleton('checkout/cart'); 
$quoteItems = Mage::getSingleton('checkout/session')
                  ->getQuote()
                  ->getItemsCollection();
 
foreach( $quoteItems as $item ){
    $cart->removeItem( $item->getId() );    
}
$cart->save();

My question is how can i clear cart by user id, not by session?