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

Suppress shipping option JS alert in BC

Participant ,
Aug 24, 2016 Aug 24, 2016

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

TOPICS
eCommerce

Views

996

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
Explorer ,
Aug 27, 2016 Aug 27, 2016

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.

Adobe Business Catalyst: Removing alert box when click on the Add to Cart button | Adobe Business Ca...

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

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

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.

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
New Here ,
Jan 04, 2018 Jan 04, 2018

Copy link to clipboard

Copied

I Am Use This Code But Its Not Working

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 ,
Jan 14, 2018 Jan 14, 2018

Copy link to clipboard

Copied

LATEST

rajm59646193, a bit more information would be helpful in order for me to help you troubleshoot.

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