I want to show Magento all success/error message as alert or in a modal. Is there any way to do that?

  • Is there a reason for that? as if you keep showing success/error messages with modal, browsers will give the user option to block them. So after 2-3 modal, all of your modals on the site will be blocked if the user ask for.
    – Korbin
    Commented Jul 29, 2019 at 11:30

1 Answer 1


You can use this code for showing a message as Modal to your phtml file

<button type="submit" id="gotoreviewform" class="action submit primary write-action"><span>Click to Open</span></button>
<div id="popup-mpdal" style="display: none;" >
    <div class="message info notlogged" id="review-form">
            <?php /* @noEscape */ echo __('Popup Modal Message!') ?>
<script type="text/javascript">
require(['jquery', 'Magento_Ui/js/modal/modal'], function($, modal){

var options = {
    type: 'popup',
    responsive: true,
    innerScroll: true,
    buttons: [{
        text: $.mage.__('Continue'),
        class: '',
        click: function () {
var popup = modal(options, $('#popup-mpdal'));


        $('html, body').animate({
            scrollTop: $("#review-form").offset().top
        }, 1000);


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.