1

I need to show a message after customer logs in. In order to do so, I created a afterAuthenticate() plugin that gets called both when the customer logs in from the login page and when the customer logs from the checkout page.

However, the plugin should show a message to the customer. The message is correctly shown when the customer logs in from the login page but it doesn't appear when the customer logs in from the checkout page.

I used the \Magento\Framework\Message\ManagerInterface::addWarningMessage('my message') . I also tried using the complex message, creating the di and then the phtml with my messsage, but the result is the same: the message shows on all pages but not on checkout page.

How can I add a message on the checkout page?

2
  • Are you talking about the default Magento checkout page?
    – Amit Bera
    Feb 8, 2023 at 16:22
  • @AmitBera yes, the default checkout page. I can see from checkout_index_index that the container for page.messages has been removed and a displayArea for messages has been added instead inside the jsLayout but I don't know how to add messages there
    – Lou Nik
    Feb 8, 2023 at 17:14

1 Answer 1

1

As per my understanding, Magento Checkout page login operation is happening from \Magento\Customer\Controller\Ajax\Login::execute class and this controller return response as JSON.Like below :

{"errors":true,"message":"Invalid login or password."} 

or

  {"errors":false,"message":"Login successful."} 

This message is rendered on the checkout page.To suggest that if you return your customer message on "message", it is better.

1
  • you're right, that Ajax calls the authenticate() in the middle of the execute method so whatever I do in my afterAuthenticate() is useless on the checkout.. so there is no way I can keep my code to a minimum, I have to alter a bunch of different method, I hoped I could avoid that but it won't be possible.. Thank you a lot!!!
    – Lou Nik
    Feb 8, 2023 at 17:19

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.