0

app\design\frontend\Vendor\theme\Magento_Theme\templates\messages.phtml

<div data-bind="scope: 'messages'">
        <div data-bind="foreach: { data: cookieMessages, as: 'message' }" class="messages">
            <div data-bind="attr: {
                class: 'message-' + message.type + ' ' + message.type + ' message',
                'data-ui-id': 'message-' + message.type
            }">
                <div data-bind="html: message.text"></div>
            </div>
        </div>
        <div data-bind="foreach: { data: messages().messages, as: 'message' }" class="messages">
            <div data-bind="attr: {
                class: 'message-' + message.type + ' ' + message.type + ' message',
                'data-ui-id': 'message-' + message.type
            }">
                <div data-bind="html: message.text"></div>
            </div>
        </div>
    </div>
    <script type="text/x-magento-init">
        {
            "*": {
                "Magento_Ui/js/core/app": {
                    "components": {
                            "messages": {
                                "component": "Magento_Theme/js/view/messages"
                            }
                        }
                    }
                }
        }
    </script>

app\code\Vendor\Module\view\frontend\layout\checkout_index_index.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">

    <head>
        <title>Multi Step Checkout</title>
    </head> 

    <body>
        <referenceContainer name="columns.top">
            <referenceBlock name="messages">
                <action method="setTemplate">
                    <argument xsi:type="string" name="template">Magento_Theme::messages.phtml</argument>
                </action>
            </referenceBlock>     
        </referenceContainer>

        <container name="sidebar.additional" label="Sidebar Additional" htmlTag="div">
            <referenceBlock name="wishlist_sidebar" remove="true"/>
            <referenceBlock name="sale.reorder.sidebar" remove="true"/>
            <referenceBlock name="catalog.compare.sidebar" remove="true" />         
        </container>


        <referenceBlock name="content">

        </referenceBlock>   


    </body>
</page>

In Controller Code

$errorMsg = "Something";
$this->_messageManager->addError(__($errorMsg));
$this->_redirect('checkout', ['_fragment' => 'cart']);

But Even after all It's not triggering Error Messages.

enter image description here

  • have you checked success message is displaying? – Prashant Valanda May 18 at 6:18
  • @prashant valanda, it's not displaying any success or error message – Hitesh Balpande May 18 at 6:25
  • @All,please check the link , it's worked for me. github.com/magento/magento2/issues/7561#issuecomment-432606764 – Hitesh Balpande May 20 at 8:08
  • @PrashantValanda i solved this error issue in locals server but in live server it's not firing any messages even it's not displaying any error messages on default checkout page also – Hitesh Balpande May 29 at 7:32
  • @PrashantValanda can you please check my updated question some console error is there in our checkout page,is this issue may be causing due to this console errors – Hitesh Balpande May 29 at 7:37
0

This code worked for me

app\code\Vendor\Module\view\frontend\layout\checkout_index_index.xml

<referenceBlock name="content">        
        <block class="Magento\Framework\View\Element\Messages" name="messages" as="messages" template="Magento_Theme::messages.phtml"/>
</referenceBlock>

app\design\frontend\Vendor\theme\Magento_Theme\templates\messages.phtml

<div data-bind="scope: 'messages'">
        <div data-bind="foreach: { data: cookieMessages, as: 'message' }" class="messages">
            <div data-bind="attr: {
                class: 'message-' + message.type + ' ' + message.type + ' message',
                'data-ui-id': 'message-' + message.type
            }">
                <div data-bind="html: message.text"></div>
            </div>
        </div>
        <div data-bind="foreach: { data: messages().messages, as: 'message' }" class="messages">
            <div data-bind="attr: {
                class: 'message-' + message.type + ' ' + message.type + ' message',
                'data-ui-id': 'message-' + message.type
            }">
                <div data-bind="html: message.text"></div>
            </div>
        </div>
    </div>
    <script type="text/x-magento-init">
        {
            "*": {
                "Magento_Ui/js/core/app": {
                    "components": {
                            "messages": {
                                "component": "Magento_Theme/js/view/messages"
                            }
                        }
                    }
                }
        }
    </script>

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.