How to delete all shopping cart items of all customers in Magento?

I want to delete all shopping cart items (products added to cart) of all customers in Magento.

How can I do that?

In detail:-

Suppose, I have total 10 registered customers in my shop. They might have items (products) added to cart. I want to clear all items added to cart for all the 10 registered customers.

2 thoughts on “How to delete all shopping cart items of all customers in Magento?”

  1. My first guess would be something like,

    $items = Mage::getResourceModel('sales/quote_item_collection');
    
    foreach ($items as $item) {
        $item->delete();
    }
    

    The cart items are stored as part of a ‘quote’. Looping through them all like this might be slow, doing it in SQL is quicker but not as safe.

    TRUNCATE `sales_flat_quote_item`;
    

Leave a Reply

Your email address will not be published. Required fields are marked *