I am building an ecommerce magento site named www.bookslab.in. I had one issue in this website. I want to make compulsory for every user to check their zipcode before they buy anything from the website, because i am delivering the products in the limited area. Now i had added the exception for that. The exception is when user's zipcode is invalid then ADD_TO_CART button is disabled, this is the exception. So, the problem comes here when user checks that the zipcode he enters is wrong, so after that he enters the correct zipcode, but still the ADD_TO_CART button is disabled. To solved this issue, i want to refresh(reload) the page everytime when user clicks on CHECK button of zipcode field. Plz suggest me in the code i provided & go to my website to see the problem.
cod.phtml
<?php
/***************************************
*** Cash On Delivery ***
**************************************
*/
$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 book is not available on the above pincode')!=-1)
{
zipcode='checked';
jQuery('.btn-cart').attr('disabled', 'disabled');
}
else
{
zipcode='';
}
},
onFailure: function() { alert('Something went wrong...'); }
});
}
}
</script>
<?php } ?>
Screenshot: