After the ajax process get the error from the payment api i can see that the Magento_Ui/js/model/messages.js it triggered and the message should be added to the list but I cant see anything in the front end.

I can see also that the content of the message it is at type.push(messageObj.message);

     * Add  message to list.
     * @param {Object} messageObj
     * @param {Object} type
     * @returns {Boolean}
    add: function (messageObj, type) {
        var expr = /([%])\w+/g,

        if (!messageObj.hasOwnProperty('parameters')) {

            return true;
        message = messageObj.message.replace(expr, function (varName) {
            varName = varName.substr(1);

            if (messageObj.parameters.hasOwnProperty(varName)) {
                return messageObj.parameters[varName];

            return messageObj.parameters.shift();

        return true;

I tried with the blank template but still the same issue

----------------- UPDATE --------------------

The messages work fine if it if there is a product with shipment and the actual message shows in the payment method area as they should but in the case of virtual products with out shipping that that it is my need they stop showing.

  • Magento does not provide any onestepcheckout ferature.Do you have using any 3rd party module? – Amit Bera Apr 18 '18 at 9:58
  • yes i do but they claim to be working at there end it is my 4th day trying to get this error message working i tried to take all my code away but still no luck – open-ecommerce.org Apr 18 '18 at 10:06

Since you're using a module for the onestepcheckout it's hard to say what the issue is here. Normally my first advice is to contact the developer of the extension to solve the issue with them. But before you contact them there's a few things that you can test:

  1. Are error messages showing in the rest of the website?
  2. Are error messages working when you use the default Magento 2 checkout?

If these answers are "yes" then it's more likely a problem with the extension that you're using. If no errors are showing anywhere, then it's a completely different issue.

Messages in the default Magento 2 theme are added in default.xml of the Magento/Theme module. The page.messages container is by default added to the columns.top container.

You could check the extension layout files to make sure that they don't remove or move these container. (Does the .messages div exist in your onecheckcheckout page?)

If it's missing you could try re-adding the block yourself:

<referenceContainer name="columns.top">               
    <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"/>
  • It dosn't wok adding this code and the messages are showing with non virtual products with the shipping container (I edited my question) – open-ecommerce.org Apr 18 '18 at 14:53
  • Hmm, that's something completely different from what I understood from your question. One of the questions still applies though, do the messages work with the default Magento 2 checkout? – sduif Apr 20 '18 at 12:41
  • @sduif i tried in my custom checkout module layout/checkout_index_index.xml but even it's not displaying any error messages – Hitesh Balpande May 29 at 14:35

If you look at the end of the checkout_index_index.xml file in the Magento_Checkout module, you will see the page.messages container is removed there. I have a hunch it is removed for a specific purpose, but if you want to bring it back, you can place a new checkout_index_index.xml file in a layout folder in your theme (like app/design/frontend/MyAwesomeTheme/default/Magento_Checkout/layout/) with the following contents:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceContainer name="page.messages" remove="false" />

The false will cancel out the removal.

You can also place the file in a module folder, but then you must make sure to let your module sequence after Magento_Checkout in your module.xml. Like:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="AwesomeVendor_AwesomeModule" setup_version="1.0.0">
            <module name="Magento_Checkout" />

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.