1

I have made Observer on event "sales_quote_merge_before" to remove abandoned cart items when customer logs in (from Go to Checkout). After login Minicart shows only guest cart items (no items from abandoned cart), but on checkout/cart and checkout/ carts are still merged and show all items (guest and abandoned combined)

Any ideas what I'm doing wrong?

public function execute(Observer $observer) {
     $this->_logger->debug('SingleVendorMergeObs:sales_quote_merge_before');
       $event = $observer->getEvent();

     /** @var $quote \Magento\Sales\Model\Quote */
     $quote = $observer->getQuote();
     $quote->removeAllItems();
     $quote->save();
}

bumped to the homepage by Community 14 hours ago

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

0

I made module to clear all cart items(not abandoned cart, sorry), like below.

$this->_cart->truncate();

This function clear cart before login, and abandoned cart items keep. I hope this will help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.