How to empty all cart items in magento cart (all PCs around the world)
2 answers
try below code.
protected $quoteFactory;
public function __construct(
...
\Magento\Quote\Model\QuoteFactory $quoteFactory,
....
) {
....
$this->quoteFactory = $quoteFactory;
....
}
$quoteCollection = $this->quoteFactory->create()->getCollection()
->addFieldToFilter('is_active', 1);
foreach ($quoteCollection as $item) {
$item->delete();
}
0
source to share