0

I am building the magento site named www.bookslab.in. I want to remove the alert message "Above field is mandatory". It appears when users clicks on ADD TO CART button without checking the zipcode which is mandatory for every users. I want to remove this alert message because it does not need when user know that the Zipcode field is mandatory. I am attaching the screenshot for better understanding. I had added the cod.phtml code & updated my screenshot image to understand better.

cod.phtml

<?php


$msgData = Mage::helper('netgo_cod')->getConfigData(); 
if($msgData['zip_status'] == 1){
?>
<div class="input-box">
    <div class="z-btn">
        <label>Zip Code : </label><input type="text" placeholder="Enter your pincode" value="" name="cod" class="product-custom-option required-entry" id="cod" size="29" style='color:black; font-size:12px'>
        <button type="button" onclick="checkCOD();" name="zip-check" title="Check" class="button" id="zip-check"><span><span>Check</span></span></button>
    </div>
    <div id="cod_msg"></div>
</div>

<script>
    function checkCOD(){
             var zipcode;
        var cod = $('cod').value;
        if(cod == ''){
            $('cod_msg').update('<span class="cod-error"><?php echo $msgData['emp_msg']; ?></span>');
            return
        }else{
            $('cod_msg').update('<img src="<?php echo Mage::getBaseUrl( Mage_Core_Model_Store::URL_TYPE_WEB, true ).'media/cod/img/ajax-loader-2.gif';?>">'); 
            new Ajax.Request('<?php echo Mage::getBaseUrl().'netgo/cod/check';?>', {
                method:'post',
                parameters: {zipcode: cod}, 
                onSuccess: function(transport) {
                    var response = transport.responseText || "no response text";
                    $('cod_msg').update(response);

                    if(response.search('Delivery of the books not available')!=-1)
                                        {
                                          zipcode='checked';
                                          jQuery('.btn-cart').attr('disabled', 'disabled'); 
                                        }
                                      else
                                      {
                                      jQuery('.btn-cart').removeAttr('disabled');

                                      }

                },
                onFailure: function() { alert('Something went wrong...'); }
            });
        }
    }
</script>
<?php } ?>

enter image description here

3

You can use setTimeOut jQuery function to hide the message after it appears to users.

jQuery(document).ready(function(){
    jQuery('.btn-cart, #zip-check').click(function(){
        setTimeout(function() {
            jQuery("#cod_msg").update('')
        }, 5000);
    });
});

Here 5000 is the time in milliseconds, it defines 5 seconds, you can set it as per your requirements.

  • Okzz i will check your method & get back to you – Salman Dalal Feb 26 '17 at 13:10
  • In which file i have to add this code & on which line – Salman Dalal Feb 27 '17 at 11:33
  • You can put this code in app\design\frontend\rwd\default\template\catalog\product\view\addtocart.phtml – Jaimin Sutariya Feb 27 '17 at 12:08
  • Okzz i will check – Salman Dalal Feb 27 '17 at 18:30
  • Thank you @Jaimin that works for me & sorry for the late reply – Salman Dalal Mar 13 '17 at 7:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.