I am having an ecommerce website named www.bookslab.in. I want to restrict the users to place on order from checkout page if pincode in invalid. I had a pincode validation on my product details page, same validation i want to use on checkpage page.
For Example: If "A" want to place an order on pincode 411042, "A" validate the pincode 411042 on product details page, if "A" find the pincode 411042 is valid, then "A" proceed to checkout page & add different pincode 411043 & "A" place an order. This should be restricted, because I will get confused on which pincode i should deliver the book.
I want to restrict further bars "SHIPPING INFORMATION", "SHIPPING METHOD", "PAYMENT INFORMATION" & "ORDER REVIEW", if pincode textfield of "BILLING INFORMATION" is invalid. I am providing the screenshot for better understanding. I am also uploading the product details screenshot that has the pincode validation. I am using "Netgo_Cod" extension for zipcode validation.
Product details page screenshot:
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 } ?>
CodController.php
<?php
/***************************************
*/
class Netgo_Cod_CodController extends Mage_Core_Controller_Front_Action
{
/**
* view cod action
*
* @access public
* @return void
* @author NetGo
*/
public function checkAction()
{
$msgData = Mage::helper('netgo_cod')->getConfigData();
$cod = $this->getRequest()->getPost('zipcode');
$codObj = Mage::getModel('netgo_cod/cod')->getCollection()->addFieldToFilter('zipcode', trim($cod));
$codData = $codObj->getData();
if($codData[0]['zipcode'] != '' && $codData[0]['status'] != 0){
echo '<span class="cod-suc">'.$msgData['suc_msg'];
if($codData[0]['days'] != ''){
echo ' within '.$codData[0]['days'].' days ';
}
echo '.</span>';
}else{
echo '<span class="cod-error">'.$msgData['err_msg'].'</span>';
}
}
}
config.xml
<?xml version="1.0"?>
<!--
/***************************************
*** Cash On Delivery ***
***************************************
*
* @copyright Copyright (c) 2015
* @company NetAttingo Technologies
* @package Netgo_Cod
* @author NetGo
* @dev [email protected]
*
*/
-->
<config>
<modules>
<Netgo_Cod>
<version>1.0.2</version>
</Netgo_Cod>
</modules>
<global>
<resources>
<netgo_cod_setup>
<setup>
<module>Netgo_Cod</module>
<class>Netgo_Cod_Model_Resource_Setup</class>
</setup>
</netgo_cod_setup>
</resources>
<blocks>
<netgo_cod>
<class>Netgo_Cod_Block</class>
</netgo_cod>
</blocks>
<helpers>
<netgo_cod>
<class>Netgo_Cod_Helper</class>
</netgo_cod>
</helpers>
<models>
<netgo_cod>
<class>Netgo_Cod_Model</class>
<resourceModel>netgo_cod_resource</resourceModel>
</netgo_cod>
<netgo_cod_resource>
<class>Netgo_Cod_Model_Resource</class>
<entities>
<cod>
<table>netgo_cod_cod</table>
</cod>
</entities>
</netgo_cod_resource>
</models>
<rewrite>
<netgo_cod_checkout_onepagecontroller>
<from><![CDATA[#^/checkout/onepage/#]]></from>
<to>/netgo/checkout_onepage/</to>
</netgo_cod_checkout_onepagecontroller>
</rewrite>
</global>
<adminhtml>
<layout>
<updates>
<netgo_cod>
<file>netgo_cod.xml</file>
</netgo_cod>
</updates>
</layout>
<translate>
<modules>
<Netgo_Cod>
<files>
<default>Netgo_Cod.csv</default>
</files>
</Netgo_Cod>
</modules>
</translate>
</adminhtml>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<Netgo_Cod before="Mage_Adminhtml">Netgo_Cod_Adminhtml</Netgo_Cod>
</modules>
</args>
</adminhtml>
</routers>
</admin>
<frontend>
<routers>
<netgo_cod>
<use>standard</use>
<args>
<module>Netgo_Cod</module>
<frontName>netgo</frontName>
</args>
</netgo_cod>
</routers>
<layout>
<updates>
<netgo_cod>
<file>netgo_cod.xml</file>
</netgo_cod>
</updates>
</layout>
<translate>
<modules>
<Netgo_Cod>
<files>
<default>Netgo_Cod.csv</default>
</files>
</Netgo_Cod>
</modules>
</translate>
</frontend>
<default>
<netgo_cod>
<cod>
<breadcrumbs>1</breadcrumbs>
</cod>
</netgo_cod>
</default>
</config>