0

I am facing an issue with the subscription message. when I subscribe for the newsletter from the homepage the page reloads but successfully subscribed message is not displayed on the homepage but when I follow the same steps on the contact us page it shows successfully subscribed message. Please help.

Environment Magento - 2.3.0 PHP - 7.1

enter image description here

3 Answers 3

0

It may depends on your theme layout used for Homepage. Magento messages should appear in all pages according to this code

vendor/magento/module-theme/view/frontend/layout/default.xml

<container name="page.messages" htmlTag="div" htmlClass="page messages">
                <block class="Magento\Framework\View\Element\Template" name="ajax.message.placeholder" template="Magento_Theme::html/messages.phtml"/>
                <block class="Magento\Framework\View\Element\Messages" name="messages" as="messages" template="Magento_Theme::messages.phtml"/>
            </container>

But it may happens that your theme provider/coder has removed the messages block from homepage layout. Please make sure that you don't have any code like this in your theme

<referenceContainer name="page.messages" remove="true" />
0

First check the message block/container is present in your layout.xml, if you have used any custom theme then check theme's layout directory if they defined any layout for homepage or used default.xml file, check message container is present or not ?

Second in default magento when you subscribe the newsletter then it will refresh the page and display the success message on top of the page so that was not user friendly, i suggest create a AJAX Action and display response message below the Newsletter email box once AJAX request completed.

Please let me know if you have any query. I will guide you for further.

0

Recently i have the same issues in one of my website, as i can see in your live website message is displaying but it clear immediately on load, when i inspect the message block in your site thare is no error message, you have to check following file

/vendor/magento/module-theme/view/frontend/web/js/view/messages.js

define([
    'jquery',
    'uiComponent',
    'Magento_Customer/js/customer-data',
    'underscore',
    'jquery/jquery-storageapi'
], function ($, Component, customerData, _) {
    'use strict';

    return Component.extend({
        defaults: {
            cookieMessages: [],
            messages: []
        },

        /**
         * Extends Component object by storage observable messages.
         */
        initialize: function () {
            this._super();

            this.cookieMessages = _.unique($.cookieStorage.get('mage-messages'), 'text');
            this.messages = customerData.get('messages').extend({
                disposableCustomerData: 'messages'
            });

            // Force to clean obsolete messages
            if (!_.isEmpty(this.messages().messages)) {
                customerData.set('messages', {});
            }

            // this line clear the current messages.
            $.cookieStorage.set('mage-messages', '');
        }
    });
});

Issue is messages.js must be called multiple time in homepage. thus the last line of the above code clear out the messages every time. you have to find out why this file calling multiple times in homepage.

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.