Copy link to clipboard
Copied
Hi, when the customer chooses a shipping option in the shopping cart an alert pops up, claiming the successfully choose of a shipping option. As I only have one shipping option, I use JS to choose automatically and hide the option field with css. But the alert box still pops up every time the site loads or refreshes, i. e. every time the script changes the shipping option in background.
How can I suppress this alert? Its part of the form validation of this shipping option field, but as the field is integrated with {tag_shippingoptions}, there is no easy way to edit.
Thanks for your help,
Dennis
Copy link to clipboard
Copied
Hi Dennis,
I was trying to find the answer to this a few days ago as I've only got a free shipping option at the moment. I don't know how to suppress the alert but I did find this on styling it.
I think it looks much better than the default alert pop up and it fades out so the user doesn't have to click the ok button.
I changed the css a bit and so far put it on the shopping cart, large_product and contact form.
<span class="cartalert" style="display:none"></span>
<style>
.cartalert {
position: fixed;
bottom: 45%;
right: 5%;
padding: 2em 1.2em;
text-align: center;
background: #A1D490;
color: #FFF !important;
z-index:999999;
border-radius: 2%;
font-size: 1.2em;
}
</style>
<script>
$(function() {
window.alert = function(msg) {
msg = msg.replace('ERROR: ','');
$('.cartalert').text(msg).fadeIn().delay(2000).fadeOut()
}
});
</script>
I can't figure out how to center it on the page like the default alert, but still think it looks better.
I hope I've been of some help.
Regards
Peter
Copy link to clipboard
Copied
Realise it's been a while since you asked this Graugans GbR​, but I ran to a similar issue - needing to suppress a specific alert - and came up with the following:
<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 = 'Shipping Option Selected successfully';
// 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 someone.
Copy link to clipboard
Copied
I Am Use This Code But Its Not Working
Copy link to clipboard
Copied
rajm59646193, a bit more information would be helpful in order for me to help you troubleshoot.