skip to Main Content

When i run a script then clear cart items from all PCs which already added a cart item(s).

2

Answers


  1. Run the following Query :

    Delete FROM quote WHERE is_active=1 AND reserved_order_id IS NULL

    Now run following command from Your Magento Root directory :

    Truncate persistent_session

    Login or Signup to reply.
  2. try below code.

    protected $quoteFactory;
    
    public function __construct(
        ...
        MagentoQuoteModelQuoteFactory $quoteFactory,
        ....
    ) {
        ....
        $this->quoteFactory = $quoteFactory;
        ....
    }
    
    $quoteCollection = $this->quoteFactory->create()->getCollection()
              ->addFieldToFilter('is_active', 1);       
    
    foreach ($quoteCollection as $item) {
        $item->delete();    
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search