0

scenario - the customer added products to the basket and logged out. After sometime he again logged in, now when he checked his minicart or cart i need to remove the products which are out of stock and show the messege [xxx],[yyy] products removed due to out of stock.How can i achieve this? Thanks.

1 Answer 1

0

I would suggest a custom action on LoginPost.

<preference for="Magento\Customer\Controller\Account\LoginPost" type="Cpy\Customer\Controller\Account\LoginPost" />

In \Cpy\Customer\Controller\Account\LoginPost you can access the $customer variable after the authentication. From that variable you should be able to get the cart and mini cart of the customer and to modify them as you want.

To display the message : you can use

$this->messageManager->addErrorMessage(
                    __('we removed xxx product due to out of stock');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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