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.
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!
Copy link to clipboard
Copied
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!