Skip to main content
added 224 characters in body
Source Link
Shoaib Munir
  • 9.6k
  • 10
  • 53
  • 108

On your ajax add to cart success function you need to add following lines

//Display error if found after jquery
var messages = $.cookieStorage.get('mage-messages');
if (!_.isEmpty(messages)) {
    customerData.set('messages', {messages: messages});
    $.cookieStorage.set('mage-messages', '');
}

I was facing almost same issue and fixed by this small script

And to move notification messages top of the page, please follow this link, this will help you move messages anywhere in your code

Magento 2: Change message location

On your ajax add to cart success function you need to add following lines

//Display error if found after jquery
var messages = $.cookieStorage.get('mage-messages');
if (!_.isEmpty(messages)) {
    customerData.set('messages', {messages: messages});
    $.cookieStorage.set('mage-messages', '');
}

I was facing almost same issue and fixed by this small script

On your ajax add to cart success function you need to add following lines

//Display error if found after jquery
var messages = $.cookieStorage.get('mage-messages');
if (!_.isEmpty(messages)) {
    customerData.set('messages', {messages: messages});
    $.cookieStorage.set('mage-messages', '');
}

I was facing almost same issue and fixed by this small script

And to move notification messages top of the page, please follow this link, this will help you move messages anywhere in your code

Magento 2: Change message location

Source Link
Shoaib Munir
  • 9.6k
  • 10
  • 53
  • 108

On your ajax add to cart success function you need to add following lines

//Display error if found after jquery
var messages = $.cookieStorage.get('mage-messages');
if (!_.isEmpty(messages)) {
    customerData.set('messages', {messages: messages});
    $.cookieStorage.set('mage-messages', '');
}

I was facing almost same issue and fixed by this small script