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.
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`;
I know, it's not related directly your question but might be help.
Inchoo has published an article a few days ago which is putting "Cart Empty" link on cart page.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.