• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Removing alert box in Add to Cart

New Here ,
Feb 20, 2015 Feb 20, 2015

Copy link to clipboard

Copied

Hi,

I really need your help on how to remove the add to cart alert box.

I thought using window.alert=function(msg){}  would help but it removes all the other alert boxes in the site.

Thank you.

TOPICS
CRM

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Feb 20, 2015 Feb 20, 2015

Copy link to clipboard

Copied

I wouldn't remove the alerts all together, just display them in a div.

Here is what I do in the shopping cart.

First open the shopping cart layout ( /Layouts/OnlineShop/shopping_cart-XX -- XX is the country code)

Right above my checkout button (aka: {tag_buybutton} ) I insert this div:

<span class="msg" style="display:none"></span>

Then, in the same layout I insert this code:

<script>

$(function() {

     window.alert = function(msg) {

        msg = msg.replace('ERROR: ','');

        $('.msg').text(msg).fadeIn().delay(5000).fadeOut()

     }

});

</script>

If you add this code to your site template it will remove all your alerts; this is why you only add the code to your layout.

Hope this helps!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 30, 2017 Oct 30, 2017

Copy link to clipboard

Copied

LATEST

This is what you gotta do soldieroflight​ (I realise it's probably two years too late but for what it's worth 😞

<script type="text/javascript">

     // saves the alert to be referenced later if conditions for exclusion are not met

     window.default = window.alert;

     window.alert = function alert(msg) {

         // defines the text to trigger exclusion - doesn't have to be the entire message

          var excludedAlert = 'added to your cart';

          // if alert contains aforementioned text

          if (msg.indexOf(excludedAlert) != -1) {

               // do nothing

               console.log('Suppressed!');

          }

          // otherwise

          else {

               // display alert

               window.default(msg);

          }

     };

</script>

Hope that helps!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines