medved Posted August 30, 2006 Share Posted August 30, 2006 I?ve downloaded ?Local Delivery v1.6? http://www.oscommerce.com/community/contributions,1993 In this contribution I need to enter the whole postal code for example M5A 2T5 But city like Toronto has so many postal codes that it would take me ages to enter them all. By entering just the first three digits, for example M5A I would rapidly eliminate the number of postal codes because each postal code in Toronto starts with letter M. Is there any contribution that is able to read the postal code just by the first three digits and is not case sensitive? Or is there any other solution for this problem? Please help. Quote Link to comment Share on other sites More sharing options...
medved Posted September 1, 2006 Author Share Posted September 1, 2006 anyone? please. Quote Link to comment Share on other sites More sharing options...
insomniac2 Posted September 1, 2006 Share Posted September 1, 2006 (edited) Hi medved, Here is some code I modified that looks in the orders table for the first 3 digits of Canadian and US postcodes than diplays a link which will tell you the postcode details. It is just experimental. You could modify it to or take code the code structure and maybe add or customize it to what you need. I was just playing around with the code and this is what I came up with to quickly see where Canadian orders were coming from becuase the original contribution only checked for US post codes.. Just copy and paste it to a php file than access it to see its basic functions: (Orders Tracking code originally developed by Kieth Waldorf) CODE: <?php /* $Id: orders_tracking_postcodes.php, v2.4 August 20, 2004 01:30:00 osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Orders Tracking originally developed by Kieth Waldorf Other Orders Tracking functions added to package by Jared Call Released under the GNU General Public License */ require('includes/application_top.php'); // if no year has been selected, use current year if (isset($_GET['year'])) { $year = $_GET['year']; } else { $year = date('Y'); // current year } // if selected a month but not year, assume current year if ($_GET['year'] == '') { $year = date('Y'); // current year } // if a month has been selected, set the date range for just that month if (isset($_GET['month'])) { $startmonth = $_GET['month']; $endmonth = $startmonth; } // if no month has been selected, we want entire year of data if ($_GET['month'] == '') { $startmonth = 01; $endmonth = 12; } ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <br> <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> <script language="javascript" src="includes/general.js"></script> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="2" cellpadding="2"> <br> <!-- body_text //--> <td width="100%" valign="top"><table border="0" align="center" width="95%" cellspacing="0" cellpadding="2"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"></td> </tr> </table></td> </tr> <tr> <td><table border="0" align="center" width="100%" cellspacing="0" cellpadding="2"> <tr> <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> <td class="pageHeading" align="left"><?php echo tep_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td> <td align="right"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr><?php echo tep_draw_form('search', FILENAME_STATS_ORDERS_TRACKING_POSTCODES, '', 'get'); ?> <td class="smallText" align="right"> <?php echo HEADING_SELECT_YEAR . ' ' . tep_draw_input_field('year', '', 'size="4" maxlength="4"'); ?></td> <td class="smallText" align="left"> <td class="smallText"><?php echo HEADING_SELECT_MONTH . ' ' . tep_draw_input_field('month', '', 'size="2" maxlength="2"'); ?></td> <td class="smallText" align="left"> <?php echo HEADING_SELECT_POSTPREFIX . ' ' . tep_draw_input_field('postcode_prefix', '', 'size="3" maxlength="3"'); ?> <?php echo tep_image_submit('button_submit.gif', HEADING_TITLE_RECALCULATE, 'align="absmiddle"') . '</a>'; ?> </td> </form> </tr> </table></td> </tr> </table></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr class="dataTableHeadingRow"> <td class="dataTableHeadingContent" align="left"> <?php echo HEADING_ZONE; ?></td> <td class="dataTableHeadingContent" align="center"><?php echo HEADING_ORDER_COUNT; ?></td> </tr> <?php if ((isset($_GET['postcode_prefix'])) && ($_GET['postcode_prefix'] != '')) { $prefix = '"' . $_GET['postcode_prefix'] . '"'; //$prefix = preg_replace( "/-/", " ", $_GET['postcode_prefix']) . '"'; //$_GET['postcode_prefix'] = preg_replace( "/-/", " ", $_GET['postcode_prefix'] ); $postcode_query = tep_db_query("select count(*) as count, customers_postcode from " . TABLE_ORDERS . " where substring(customers_postcode,1,3) = $prefix and customers_postcode IS NOT NULL and date_purchased >= '$year-$startmonth-01 00:00:00' and date_purchased <= '$year-$endmonth-31 11:59:59' group by customers_postcode order by customers_postcode DESC LIMIT 50"); while ($customers_location = tep_db_fetch_array($postcode_query)) { $location_contents .= '<tr class="dataTableRow"><td class="dataTableContent"> ' . $customers_location['customers_postcode'] . '</font>'; if (is_numeric($customers_location['customers_postcode'])) { $location_contents .= ' [ <a href=' . ZIP_URL . $customers_location['customers_postcode] . '" target="_blank">' . ZIP_CODE_LOOKUP . '</a> ]'; } elseif (($customers_location['customers_postcode'])) { // this one takes out the any hyphens $location_contents .= ' [ <a href=' . POST_CODE_URL . substr($customers_location['customers_postcode],0,3) . '/' . substr(str_replace('-', '', $customers_location['customers_postcode']),3,5) . '" target="_blank">' . POST_CODE_LOOKUP . '</a> ]'; } $location_contents .= '</td><td class="dataTableContent" align="center">' . $customers_location['count'] . '</td></tr>'; } } else { $location_query = tep_db_query("select count(*) as count, substring(customers_postcode,1,3) as customers_postcode from " . TABLE_ORDERS . " where customers_postcode IS NOT NULL and date_purchased >= '$year-$startmonth-01 00:00:00' and date_purchased <= '$year-$endmonth-31 11:59:59' group by customers_postcode order by customers_postcode ASC"); while ($customers_location = tep_db_fetch_array($location_query)) { $location_contents .= '<tr class="dataTableRow"><td class="dataTableContent"> <a href="' . FILENAME_STATS_ORDERS_TRACKING_POSTCODES . '?postcode_prefix=' . $customers_location['customers_postcode'] . '&year=' . $year . '&month='. $month . '">' . $customers_location['customers_postcode'] . 'xx</a></font></td><td class="dataTableContent" align="center">' . $customers_location['count'] . '</td></tr>'; } } echo $location_contents; ?> </table></td> </tr> </table></td> </tr> </table></td> </tr> </table></td> <!-- body_text_eof //--> </tr> </table> <!-- body_eof //--> <!-- footer //--> <!-- footer_eof //--> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> </body> </html> You will also need to add the FILENAME_STATS_ORDERS_TRACKING_POSTCODES to your admin/includes/filenames.php to test it. Hop that gets you started. Edited September 1, 2006 by insomniac2 Quote Link to comment Share on other sites More sharing options...
medved Posted September 1, 2006 Author Share Posted September 1, 2006 Hi insomniac2, Thank you very much for your replay. I did try it but unfortunately I don?t have any knowledge of php whatsoever so I can?t modify it in any way. I plan to get some php book asap. For now I only know well html, css. What I would really appreciate and be thankful for if you or someone would be able to upgrade contribution ?Local Delivery Option? to have an option to enter only the prefixes of the postal codes instead of the entire code in the ?Zip codes? field of the "local delivery service" shipping module. Again thank you very much for your replay. I believe you can do this and I would really appreciate it and for sure many other people as well. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.