Using FEC(create_account2.php) and FedEX, and when a user typos their zipcode, they aren't able to go back and change it. They also can't go forward since they can't select a valid shipping method.
We also are using Authorize.net AIM for payment, and it is posible to get address verification errors, but I don't know if this has the same problem as FEC+FedEx blocking checkout on customer typo.
As a work around for now, have added the following code to includes/functions/validations.php
(based on http://www.oscommerce.com/community/contributions,2632)
Note: I've also made other alterations to the code for different reasons, so the new file line numbers may not match up correctly. Also our store is USA/English only, so I didn't include multilingual support in my modifications.
function tep_validstatezip($state, $zip5) {
$allstates = array (
// US Addresses
"AA" => array ("3400034099"),
"AE" => array ("0900009999"),
"AK" => array ("9950099929"),
"AL" => array ("3500036999"),
"AP" => array ("9620096699"),
"AR" => array ("7160072999"),
"AS" => array ("9679996799"),
"AZ" => array ("8500086599"),
"CA" => array ("9000096199"),
"CO" => array ("8000081699"),
"CT" => array ("0600006389", "0639106999"),
"DC" => array ("2000020099", "2020020599"),
"DE" => array ("1970019999"),
"FL" => array ("3200033999", "3410034999"),
"FM" => array ("9694196944"),
"GA" => array ("3000031999", "3980039999"),
"GU" => array ("9691096939"),
"HI" => array ("9670096798", "9680096899"),
"IA" => array ("5000052999"),
"ID" => array ("8320083899"),
"IL" => array ("6000062999"),
"IN" => array ("4600047999"),
"KS" => array ("6600067999"),
"KY" => array ("4000042999"),
"LA" => array ("7000071499"),
"MA" => array ("0100002799"),
"MD" => array ("2060021999"),
"ME" => array ("0390004999"),
"MH" => array ("9696096970"),
"MI" => array ("4800049999"),
"MN" => array ("5500056799"),
"MO" => array ("6300065899"),
"MP" => array ("9695096959"),
"MS" => array ("3860039799"),
"MT" => array ("5900059999"),
"NC" => array ("2700028999"),
"ND" => array ("5800058899"),
"NE" => array ("6800069399"),
"NH" => array ("0300003899"),
"NJ" => array ("0700008999"),
"NM" => array ("8700088499"),
"NV" => array ("8900089899"),
"NY" => array ("0040000599", "0639006390", "1000014999"),
"OH" => array ("4300045999"),
"OK" => array ("7300074999"),
"OR" => array ("9700097999"),
"PA" => array ("1500019699"),
"PR" => array ("0060000799", "0090000999"),
"PW" => array ("9694096940"),
"RI" => array ("0280002999"),
"SC" => array ("2900029999"),
"SD" => array ("5700057799"),
"TN" => array ("3700038599"),
"TX" => array ("7500079999", "8850188599"),
"UT" => array ("8400084799"),
"VA" => array ("2010520199", "2200024699"),
"VI" => array ("0080000899"),
"VT" => array ("0500005999"),
"WA" => array ("9800099499"),
"WI" => array ("5300054999"),
"WV" => array ("2470026999"),
"WY" => array ("8200083199"));
// if you use a drop down list for state selection, ensuring valid data,
// isset is not needed. (Warnings can not be turned off with: @foreach...)
if (isset($allstates[$state])) {
//just do the main part of code
$zip5 = substr($zip5, 0,5);
foreach($allstates[$state] as $ziprange) {
if (($zip5 >= substr($ziprange, 0, 5)) && ($zip5 <= substr($ziprange,5))) {
return true; // on match, return true
}
}
}
// on no match, return false
return false;
}
and changed the code in create_account2.php lines
*** New files for fec/create_account2.php 2006-05-04 14:13:28.000000000 -0500
--- create_account2.php 2006-08-23 10:07:56.216682570 -0500
***************
*** 221,230 ****
$check = tep_db_fetch_array($check_query);
$entry_state_has_zones = ($check['total'] > 0);
if ($entry_state_has_zones == true) {
! $zone_query = tep_db_query("select distinct zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and (zone_name like '" . tep_db_input($state) . "%' or zone_code like '%" . tep_db_input($state) . "%')");
if (tep_db_num_rows($zone_query) == 1) {
$zone = tep_db_fetch_array($zone_query);
$zone_id = $zone['zone_id'];
} else {
$error = true;
$messageStack->add('create_account', ENTRY_STATE_ERROR_SELECT);
--- 236,249 ----
$check = tep_db_fetch_array($check_query);
$entry_state_has_zones = ($check['total'] > 0);
if ($entry_state_has_zones == true) {
! $zone_query = tep_db_query("select distinct zone_id, zone_code from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and (zone_name like '" . tep_db_input($state) . "%' or zone_code like '%" . tep_db_input($state) . "%')");
if (tep_db_num_rows($zone_query) == 1) {
$zone = tep_db_fetch_array($zone_query);
$zone_id = $zone['zone_id'];
+ if (!tep_validstatezip($zone['zone_code'],$postcode)) {
+ $error = true;
+ $messageStack->add('create_account', 'Billing State selected does not match zipcode entered. ('.$zone['zone_code'].','.$postcode.')');
+ }
} else {
$error = true;
$messageStack->add('create_account', ENTRY_STATE_ERROR_SELECT);
***************
*** 267,276 ****
$shipping_check = tep_db_fetch_array($shipping_check_query);
$entry_state_has_zones = ($shipping_check['total'] > 0);
if ($entry_state_has_zones == true) {
! $shipping_zone_query = tep_db_query("select distinct zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and (zone_name like '" . tep_db_input($shipping_state) . "%' or zone_code like '%" . tep_db_input($shipping_state) . "%')");
if (tep_db_num_rows($shipping_zone_query) == 1) {
$shipping_zone = tep_db_fetch_array($shipping_zone_query);
$shipping_zone_id = $shipping_zone['zone_id'];
} else {
$error = true;
$messageStack->add('create_account', ENTRY_SHIPPING_STATE_ERROR_SELECT);
--- 286,299 ----
$shipping_check = tep_db_fetch_array($shipping_check_query);
$entry_state_has_zones = ($shipping_check['total'] > 0);
if ($entry_state_has_zones == true) {
! $shipping_zone_query = tep_db_query("select distinct zone_id, zone_code from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and (zone_name like '" . tep_db_input($shipping_state) . "%' or zone_code like '%" . tep_db_input($shipping_state) . "%')");
if (tep_db_num_rows($shipping_zone_query) == 1) {
$shipping_zone = tep_db_fetch_array($shipping_zone_query);
$shipping_zone_id = $shipping_zone['zone_id'];
+ if (!tep_validstatezip($shipping_zone['zone_code'],$shipping_postcode)) {
+ $error = true;
+ $messageStack->add('create_account', 'Shipping State selected does not match zipcode entered. ('.$shipping_zone['zone_code'].','.$shipping_postcode.')');
+ }
} else {
$error = true;
$messageStack->add('create_account', ENTRY_SHIPPING_STATE_ERROR_SELECT);
***************
*** 551,558 ****
if ($HTTP_POST_VARS['action'] == 'process') {
if ($entry_state_has_zones == true) {
$zones_array = array();
! $zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' order by zone_name");
while ($zones_values = tep_db_fetch_array($zones_query)) {
$zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);
}
echo tep_draw_pull_down_menu('state', $zones_array);
--- 574,589 ----
if ($HTTP_POST_VARS['action'] == 'process') {
if ($entry_state_has_zones == true) {
$zones_array = array();
! $zones_query = tep_db_query("select zone_name, zone_code from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' order by zone_name");
! $def_state = '';
! if (isset($_POST['state'])) {
! $def_state=strtoupper(trim($_POST['state']));
! }
while ($zones_values = tep_db_fetch_array($zones_query)) {
+ if ($def_state != '' and ($def_state == strtoupper($zones_values['zone_name']) or
+ $def_state == strtoupper($zones_values['zone_code']))) {
+ array_unshift($zones_array, array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']));
+ }
$zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);
}
echo tep_draw_pull_down_menu('state', $zones_array);
***************
*** 680,689 ****
if ($HTTP_POST_VARS['action'] == 'process') {
if ($entry_state_has_zones == true) {
$zones_array = array();
! $zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' order by zone_name");
while ($zones_values = tep_db_fetch_array($zones_query)) {
$zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);
}
echo tep_draw_pull_down_menu('shippingstate', $zones_array);
} else {
echo tep_draw_input_field('shippingstate');
--- 715,733 ----
if ($HTTP_POST_VARS['action'] == 'process') {
if ($entry_state_has_zones == true) {
$zones_array = array();
! $zones_query = tep_db_query("select zone_name, zone_code from " . TABLE_ZONES . " where zone_country_id = '" . (int)$shipping_country . "' order by zone_name");
! $def_state = '';
! if (isset($_POST['state'])) {
! $def_state=strtoupper(trim($_POST['state']));
! }
while ($zones_values = tep_db_fetch_array($zones_query)) {
+ if ($def_state != '' and ($def_state == strtoupper($zones_values['zone_name']) or
+ $def_state == strtoupper($zones_values['zone_code']))) {
+ array_unshift($zones_array, array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']));
+ }
$zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);
}
+
echo tep_draw_pull_down_menu('shippingstate', $zones_array);
} else {
echo tep_draw_input_field('shippingstate');
Couple of minor typos:
create_account2.php line 410
create_account3.php line 408
{if($create_password==1){$email_test .=ASSWORD_CREATED.': '.$passwords;}
Should probably be .= PASSWORD_CREATED
Some minor HTML changes and adding support for none-javascript users.
*** New files for fec/create_account2.php 2006-05-04 14:13:28.000000000 -0500
--- create_account2.php 2006-08-23 10:07:56.216682570 -0500
***************
*** 43,48 ****
--- 43,63 ----
$gender = false;
}
}
+
+ if (isset($HTTP_POST_VARS['copy']) and $HTTP_POST_VARS['copy'] == 'checkbox' and $HTTP_POST_VARS['javascript'] == 'no') {
+ foreach(array('firstname'=>'ShipFirstName','lastname'=>'ShipLastName','country'=>'shipcountry',
+ 'shipcompany'=>'shipcompany','street_address'=>'ShipAddress','suburb'=>'shipsuburb',
+ 'City'=>'ShipCity','postcode'=>'shippostcode','state'=>'shippingstate') as $billing_field => $shipping_field) {
+ if (isset($HTTP_POST_VARS[$billing_field])) {
+ $HTTP_POST_VARS[$shipping_field] = $HTTP_POST_VARS[$billing_field];
+ $$shipping_field = $HTTP_POST_VARS[$billing_field];
+ }
+ if (isset($_POST[$billing_field])) {
+ $_POST[$shipping_field] = $_POST[$billing_field];
+ }
+ }
+ }
+
//START REGISTRATION CODE
$createaccount='N';
//next two lines gives you a temporary fixed password you can change to what you like
***************
*** 631,639 ****
<tr bgcolor="#003399">
<td colspan=2 width="100%" bgcolor="#003399">
<b><font color=white size="-1" face="arial, helvetica">Shipping Information</font></b>
! <font color=white size="-2" face="arial, helvetica">
(Check to use Billing Information: <input type="checkbox" name="copy"
! OnClick="java script:ShipToBillPerson(this.form);" value="checkbox"> )
</td>
</tr>
<tr>
--- 666,674 ----
<tr bgcolor="#003399">
<td colspan=2 width="100%" bgcolor="#003399">
<b><font color=white size="-1" face="arial, helvetica">Shipping Information</font></b>
! <font color=white size="-2" face="arial, helvetica"><label>
(Check to use Billing Information: <input type="checkbox" name="copy"
! OnClick="java script:ShipToBillPerson(this.form);" value="checkbox"></label> )
</td>
</tr>
<tr>
***************
*** 655,661 ****
?>
<tr>
<td class="infoBoxContents"><?php echo ENTRY_STREET_ADDRESS; ?></td>
! <td class = "infoBoxContents"><tt><font size="2"><input name="ShipAddress" value="<? echo $ShipAddress; ?>" size="20"></font></tt><? echo ' <span class="inputRequirement">' . ENTRY_CITY_TEXT . '</span>'; ?></td>
</tr>
</tr>
<?php
--- 690,696 ----
?>
<tr>
<td class="infoBoxContents"><?php echo ENTRY_STREET_ADDRESS; ?></td>
! <td class = "infoBoxContents"><tt><font size="2"><input name="ShipAddress" value="<? echo $shipping_street_address; ?>" size="20"></font></tt><? echo ' <span class="inputRequirement">' . ENTRY_CITY_TEXT . '</span>'; ?></td>
</tr>
</tr>
<?php
***************
*** 745,750 ****
--- 793,804 ----
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2" valign="top">
</td><td width="100%" border="1"> </td><td width="100%" border="1" valign="top"><center>
+ <input type="hidden" name="javascript" value="no">
+ <script type="text/javascript">
+ <!--
+ document.checkout.javascript.value='yes';
+ //-->
+ </script>
<?php
echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONFIRM_ORDER) . '</form></td>';
?>