Jump to content
bad_lemming

[Contribution] - USPS Methods

Recommended Posts

Now for my question. The install suggests we skip the testing, is this wise? I am a little uncomfortable doing this. Is there any reason why I shouldn't test (like it wouldn't work anyways?)

Share this post


Link to post
Share on other sites

Derrick,

 

Your feelings do you credit, normally. In this case, don't worry about it. The code has been thoroughly tested by hundreds of installations. Also, even if you configure it wrong, it won't really break anything.

 

ed


Answers to osCommerce's most persistent questions! Tips & Tricks | Configuration | Common Problems.

Seek and ye shall find Contributions.

My Contributions

My Blog

Share this post


Link to post
Share on other sites

appreciate the fast reply. Well, part of my mistrust is the module, and part of it is my inexperience, I have not gotten familiar with the way things work, so I would like to make a few test purchases to get used to how it works. Is something like this possible after install? Will it work if I test for awhile just cause i am a panty?

Share this post


Link to post
Share on other sites

Go ahead and make test purchases. You should always do that.

 

I think the instructions may have meant don't worry about using the test server of USPS, which may take time to sign up and get approved.

 

Just install it and test it during checkout on your normal site on the usps production server.

 

When you install the module, you will understand what I mean.

Share this post


Link to post
Share on other sites

I've been having sudden trouble with this mod. I have tried several versions of the usps methods contribution and other usps contributions and have read all posts I can find everywhere regarding these errors. I see no solution so I want to present the problem here.

 

The error on https://www.mystore.com/catalog/checkout_shipping.php is:

 

Warning: feof(): supplied resource is not a valid stream resource in /home/www/mystore/catalog/includes/classes/http_client.php on line 385

 

Warning: fgets(): supplied resource is not a valid stream resource in /home/www/mystore/catalog/includes/classes/http_client.php on line 386

 

repeats infinitely

 

It only happens in domestic when display transit times are enabled, otherwise it works fine. The module worked fine this morning and I can't identify what changed if anything to break it. I have another shop on the same domain that works with fine with it but the whole shop is very different.

 

It seems this problem has been reported a lot and everyone just fixes it by turning off transit times. But it was working fine! And I want transit times.

 

Surely by now someone must know what the cause of cure of this error is.

 

I have uninstalled and reinstalled so many times with so many modules. All the methods one have the same error and all the non methods ones work fine.

 

Please help

 

Edward


I have moved on from oscommerce to magento and no longer monitoring this site.

Share this post


Link to post
Share on other sites

Hi, I just installed this contribution and everything seems to work in admin but when you go to checkout this is what you get

 

United States Postal Service

An error occured with the USPS shipping calculations.

If you prefer to use USPS as your shipping method, please contact the store owner.

 

Any chance I can get some help with this? It would be greatly appreciated.

Edited by wnelson0

Share this post


Link to post
Share on other sites
Wayne,

 

Are you still in "Testing" mode?  If so, switch to "Production."  Some people say you need to e-mail or call them a second time.

 

ed

 

USPS put me in production and now it work great!

Thanks for the contribution!

 

Wayne

Share this post


Link to post
Share on other sites
I made this thread in an effort to consolidate issues with this Contribution.

 

http://www.oscommerce.com/community/contri...ch,USPS+Methods

 

 

This contribution seems to be an easy one to install, but I am having problems. I made all changes per instructions, but I received error message that appeared to be a dump of the instructions with a message that there was a missing function. Anyway, because it was late I decided to just go back to what I had prior to changes. So, since I had saved all files -- the two usps.php files, modules.php, and general.php, I deleted the files from the contribution and copied the original files back in. Now I get the following messages:

Warning: main(includes/languages/.php): failed to open stream: No such file or directory in /hsphere/local/home/name/mydomain.com/admin/includes/application_top.php on line 130

 

Warning: main(includes/languages/.php): failed to open stream: No such file or directory in /hsphere/local/home/name/mydomain.com/admin/includes/application_top.php on line 130

 

Fatal error: main(): Failed opening required 'includes/languages/.php' (include_path='.:/usr/local/lib/php') in /hsphere/local/home/name/mydomains.com/admin/includes/application_top.php on line 130

 

I can't get back to where I was, although I copied the original files back into the directories.

 

I don't know what to do.

Share this post


Link to post
Share on other sites

Greetings!

 

I had a USPS mod installed, that did not work, so I called USPS, and they switched me to Production server. However, I still got this error:

United States Postal Service

An error occured with the USPS shipping calculations.

If you prefer to use USPS as your shipping method, please contact the store owner.

 

So, I just removed (uninstalled) that mod, downloaded and installed this mod. When I clicked on "Edit" to edit my information, I got this error:

Fatal error: Call to undefined function: tep_cfg_select_multioption() in .../public_html/catalog/admin/modules.php(212) : eval()'d code on line 1

Does anybody know what that means?

 

Thanks!

Dave


I am a little pencil in the hand of a writing God who is sending a love letter to the world.

--Mother Teresa

Share this post


Link to post
Share on other sites

Oh, problem solved. Thanks

 

Forgot to add the code in the general.php and modules.php files.


I am a little pencil in the hand of a writing God who is sending a love letter to the world.

--Mother Teresa

Share this post


Link to post
Share on other sites

I have installed the usps mod, I am in production mode, I received confermation from usps that they have me in production mode.

The moment the page loads you see this error:

United States Postal Service

 

An error occured with the USPS shipping calculations.

If you prefer to use USPS as your shipping method, please contact the store owner.

 

Plus there isn't a radio button to select usps. In fact there does not seem to be any method for selecting that option. And the usps icon does not show.

 

Any suggestions?

 

Thank You,

Share this post


Link to post
Share on other sites
I have installed the usps mod, I am in production mode, I received confermation from usps that they have me in production mode.

The moment the page loads you see this error:

United States Postal Service 

 

An error occured with the USPS shipping calculations.

If you prefer to use USPS as your shipping method, please contact the store owner.

 

Plus there isn't a radio button to select usps. In fact there does not seem to be any method for selecting that option.  And the usps icon does not show.

 

Any suggestions?

 

Thank You,

This was the same problem I had, sounds like you don't have the USPS icon uploaded to your website, it should be showing up.

 

Did you make the correct modifications to the general.php and modules.php files?

 

Dave


I am a little pencil in the hand of a writing God who is sending a love letter to the world.

--Mother Teresa

Share this post


Link to post
Share on other sites

Ugh! it won't let me edit my post. Here are the other suggestions...

 

Suggestions: in Admin > Configuration > Shipping / Packaging:

Make sure your country of origin and postal code are correct.

 

In Admin > Modules > Shipping > USPS:

Server should be set to "production"

Double check your USPS user ID and Password.

 

Did you make the correct modifications to the general.php and modules.php files?

 

When testing, try an address that is not your shipping address, but make sure it is not a 'junk' (fake) test address.

 

Dave


I am a little pencil in the hand of a writing God who is sending a love letter to the world.

--Mother Teresa

Share this post


Link to post
Share on other sites
Ugh! it won't let me edit my post. Here are the other suggestions...

 

Suggestions: in Admin > Configuration > Shipping / Packaging:

Make sure your country of origin and postal code are correct.

 

In Admin > Modules > Shipping > USPS:

Server should be set to "production"

Double check your USPS user ID and Password.

 

Did you make the correct modifications to the general.php and modules.php files?

 

When testing, try an address that is not your shipping address, but make sure it is not a 'junk' (fake) test address.

 

Dave

Thank you for your response Dave.... I will check all the above and see what I need to do.

Share this post


Link to post
Share on other sites
Thank you for your response Dave.... I will check all the above and see what I need to do.

Well Dave... I have double checked... All code is inserted, I still get the same error here are my files and lines of code;

My Admin/Modules.php

/*
 $Id: modules.php,v 1.47 2003/06/29 22:50:52 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License

 Updated for: Authorize.net Consolidated
 Date: March 24, 2004
 Added: Ability to create checkboxes in admin panel (see below)
 Author: Austin Renfroe (Austin519)
 Email: Austin519@aol.com
*/

 require('includes/application_top.php');

 $set = (isset($HTTP_GET_VARS['set']) ? $HTTP_GET_VARS['set'] : '');

 if (tep_not_null($set)) {
   switch ($set) {
     case 'shipping':
       $module_type = 'shipping';
       $module_directory = DIR_FS_CATALOG_MODULES . 'shipping/';
       $module_key = 'MODULE_SHIPPING_INSTALLED';
       define('HEADING_TITLE', HEADING_TITLE_MODULES_SHIPPING);
       break;
     case 'ordertotal':
       $module_type = 'order_total';
       $module_directory = DIR_FS_CATALOG_MODULES . 'order_total/';
       $module_key = 'MODULE_ORDER_TOTAL_INSTALLED';
       define('HEADING_TITLE', HEADING_TITLE_MODULES_ORDER_TOTAL);
       break;
     case 'payment':
     default:
       $module_type = 'payment';
       $module_directory = DIR_FS_CATALOG_MODULES . 'payment/';
       $module_key = 'MODULE_PAYMENT_INSTALLED';
       define('HEADING_TITLE', HEADING_TITLE_MODULES_PAYMENT);
       break;
   }
 }

 $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 if (tep_not_null($action)) {
   switch ($action) {
  case 'save':
    while (list($key, $value) = each($HTTP_POST_VARS['configuration'])) {
  if( is_array( $value ) ){
         $value = implode( ", ", $value);
   $value = ereg_replace (", --none--", "", $value);
     }

/********************************
*  Addition for Authorize.net Consolidated
*  by Austin519 - CVV PopUp Window 
*  If using a custom modules.php
*  add in the following line
********************************/

      //if (is_array($value)) $value = implode( ", ", $value);

/*******************************/

      tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $value . "' where configuration_key = '" . $key . "'"); 
    }
       tep_redirect(tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $HTTP_GET_VARS['module']));
       break;
     case 'install':
     case 'remove':
       $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
       $class = basename($HTTP_GET_VARS['module']);
       if (file_exists($module_directory . $class . $file_extension)) {
         include($module_directory . $class . $file_extension);
         $module = new $class;
         if ($action == 'install') {
           $module->install();
         } elseif ($action == 'remove') {
           $module->remove();
         }
       }
       tep_redirect(tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class));
       break;
   }
 }
?>
<!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>
<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">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
     <tr>
       <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
           <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr class="dataTableHeadingRow">
               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_MODULES; ?></td>
               <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_SORT_ORDER; ?></td>
               <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>
             </tr>
<?php
 $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
 $directory_array = array();
 if ($dir = @dir($module_directory)) {
   while ($file = $dir->read()) {
     if (!is_dir($module_directory . $file)) {
       if (substr($file, strrpos($file, '.')) == $file_extension) {
         $directory_array[] = $file;
       }
     }
   }
   sort($directory_array);
   $dir->close();
 }

 $installed_modules = array();
 for ($i=0, $n=sizeof($directory_array); $i<$n; $i++) {
   $file = $directory_array[$i];

   include(DIR_FS_CATALOG_LANGUAGES . $language . '/modules/' . $module_type . '/' . $file);
   include($module_directory . $file);

   $class = substr($file, 0, strrpos($file, '.'));
   if (tep_class_exists($class)) {
     $module = new $class;
     if ($module->check() > 0) {
       if ($module->sort_order > 0) {
         $installed_modules[$module->sort_order] = $file;
       } else {
         $installed_modules[] = $file;
       }
     }

     if ((!isset($HTTP_GET_VARS['module']) || (isset($HTTP_GET_VARS['module']) && ($HTTP_GET_VARS['module'] == $class))) && !isset($mInfo)) {
       $module_info = array('code' => $module->code,
                            'title' => $module->title,
                            'description' => $module->description,
                            'status' => $module->check());

       $module_keys = $module->keys();

       $keys_extra = array();
       for ($j=0, $k=sizeof($module_keys); $j<$k; $j++) {
         $key_value_query = tep_db_query("select configuration_title, configuration_value, configuration_description, use_function, set_function from " . TABLE_CONFIGURATION . " where configuration_key = '" . $module_keys[$j] . "'");
         $key_value = tep_db_fetch_array($key_value_query);

         $keys_extra[$module_keys[$j]]['title'] = $key_value['configuration_title'];
         $keys_extra[$module_keys[$j]]['value'] = $key_value['configuration_value'];
         $keys_extra[$module_keys[$j]]['description'] = $key_value['configuration_description'];
         $keys_extra[$module_keys[$j]]['use_function'] = $key_value['use_function'];
         $keys_extra[$module_keys[$j]]['set_function'] = $key_value['set_function'];
       }

       $module_info['keys'] = $keys_extra;

       $mInfo = new objectInfo($module_info);
     }

     if (isset($mInfo) && is_object($mInfo) && ($class == $mInfo->code) ) {
       if ($module->check() > 0) {
         echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class . '&action=edit') . '\'">' . "\n";
       } else {
         echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)">' . "\n";
       }
     } else {
       echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class) . '\'">' . "\n";
     }
?>
               <td class="dataTableContent"><?php echo $module->title; ?></td>
               <td class="dataTableContent" align="right"><?php if (is_numeric($module->sort_order)) echo $module->sort_order; ?></td>
               <td class="dataTableContent" align="right"><?php if (isset($mInfo) && is_object($mInfo) && ($class == $mInfo->code) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>
             </tr>
<?php
   }
 }

 ksort($installed_modules);
 $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = '" . $module_key . "'");
 if (tep_db_num_rows($check_query)) {
   $check = tep_db_fetch_array($check_query);
   if ($check['configuration_value'] != implode(';', $installed_modules)) {
     tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . implode(';', $installed_modules) . "', last_modified = now() where configuration_key = '" . $module_key . "'");
   }
 } else {
   tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Installed Modules', '" . $module_key . "', '" . implode(';', $installed_modules) . "', 'This is automatically updated. No need to edit.', '6', '0', now())");
 }
?>
             <tr>
               <td colspan="3" class="smallText"><?php echo TEXT_MODULE_DIRECTORY . ' ' . $module_directory; ?></td>
             </tr>
           </table></td>
<?php
 $heading = array();
 $contents = array();

 switch ($action) {
   case 'edit':
     $keys = '';
     reset($mInfo->keys);
     while (list($key, $value) = each($mInfo->keys)) {
       $keys .= '<b>' . $value['title'] . '</b><br>' . $value['description'] . '<br>';

       if ($value['set_function']) {
         eval('$keys .= ' . $value['set_function'] . "'" . $value['value'] . "', '" . $key . "');");
       } else {
         $keys .= tep_draw_input_field('configuration[' . $key . ']', $value['value']);
       }
       $keys .= '<br><br>';
     }
     $keys = substr($keys, 0, strrpos($keys, '<br><br>'));

     $heading[] = array('text' => '<b>' . $mInfo->title . '</b>');

     $contents = array('form' => tep_draw_form('modules', FILENAME_MODULES, 'set=' . $set . '&module=' . $HTTP_GET_VARS['module'] . '&action=save'));
     $contents[] = array('text' => $keys);
     $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' <a href="' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $HTTP_GET_VARS['module']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
     break;
   default:
     $heading[] = array('text' => '<b>' . $mInfo->title . '</b>');

     if ($mInfo->status == '1') {
       $keys = '';
       reset($mInfo->keys);
       while (list(, $value) = each($mInfo->keys)) {
         $keys .= '<b>' . $value['title'] . '</b><br>';
         if ($value['use_function']) {
           $use_function = $value['use_function'];
           if (ereg('->', $use_function)) {
             $class_method = explode('->', $use_function);
             if (!is_object(${$class_method[0]})) {
               include(DIR_WS_CLASSES . $class_method[0] . '.php');
               ${$class_method[0]} = new $class_method[0]();
             }
             $keys .= tep_call_function($class_method[1], $value['value'], ${$class_method[0]});
           } else {
             $keys .= tep_call_function($use_function, $value['value']);
           }
         } else {
           $keys .= $value['value'];
         }
         $keys .= '<br><br>';
       }
       $keys = substr($keys, 0, strrpos($keys, '<br><br>'));

       $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $mInfo->code . '&action=remove') . '">' . tep_image_button('button_module_remove.gif', IMAGE_MODULE_REMOVE) . '</a> <a href="' . tep_href_link(FILENAME_MODULES, 'set=' . $set . (isset($HTTP_GET_VARS['module']) ? '&module=' . $HTTP_GET_VARS['module'] : '') . '&action=edit') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a>');
       $contents[] = array('text' => '<br>' . $mInfo->description);
       $contents[] = array('text' => '<br>' . $keys);
     } else {
       $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $mInfo->code . '&action=install') . '">' . tep_image_button('button_module_install.gif', IMAGE_MODULE_INSTALL) . '</a>');
       $contents[] = array('text' => '<br>' . $mInfo->description);
     }
     break;
 }

 if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
   echo '            <td width="25%" valign="top">' . "\n";

   $box = new box;
   echo $box->infoBox($heading, $contents);

   echo '            </td>' . "\n";
 }
?>
         </tr>
       </table></td>
     </tr>
   </table></td>
<!-- body_text_eof //-->
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

Next My admin/includes/functions/general.php

/*

 $Id: general.php,v 1.160 2003/07/12 08:32:47 hpdl Exp $

 

 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com

 

 Copyright (c) 2003 osCommerce

 

 Released under the GNU General Public License

*/

function tep_array_merge($array1, $array2, $array3 = '') {

   if ($array3 == '') $array3 = array();

   if (function_exists('array_merge')) {

     $array_merged = array_merge($array1, $array2, $array3);

   } else {

     while (list($key, $val) = each($array1)) $array_merged[$key] = $val;

     while (list($key, $val) = each($array2)) $array_merged[$key] = $val;

     if (sizeof($array3) > 0) while (list($key, $val) = each($array3)) $array_merged[$key] = $val;

   }

 

   return (array) $array_merged;

 }

 

////

// Redirect to another page or site

 function tep_redirect($url) {

   global $logger;

 

   header('Location: ' . $url);

 

   if (STORE_PAGE_PARSE_TIME == 'true') {

     if (!is_object($logger)) $logger = new logger;

     $logger->timer_stop();

   }

 

   exit;

 }

 

////

// Parse the data used in the html tags to ensure the tags will not break

 function tep_parse_input_field_data($data, $parse) {

   return strtr(trim($data), $parse);

 }

 

 function tep_output_string($string, $translate = false, $protected = false) {

   if ($protected == true) {

     return htmlspecialchars($string);

   } else {

     if ($translate == false) {

       return tep_parse_input_field_data($string, array('"' => '"'));

     } else {

       return tep_parse_input_field_data($string, $translate);

     }

   }

 }

 

 function tep_output_string_protected($string) {

   return tep_output_string($string, false, true);

 }

 

 function tep_sanitize_string($string) {

   $string = ereg_replace(' +', ' ', $string);

 

   return preg_replace("/[<>]/", '_', $string);

 }

 

 function tep_customers_name($customers_id) {

   $customers = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");

   $customers_values = tep_db_fetch_array($customers);

 

   return $customers_values['customers_firstname'] . ' ' . $customers_values['customers_lastname'];

 }

 

 function tep_get_path($current_category_id = '') {

   global $cPath_array;

 

   if ($current_category_id == '') {

     $cPath_new = implode('_', $cPath_array);

   } else {

     if (sizeof($cPath_array) == 0) {

       $cPath_new = $current_category_id;

     } else {

       $cPath_new = '';

       $last_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$cPath_array[(sizeof($cPath_array)-1)] . "'");

       $last_category = tep_db_fetch_array($last_category_query);

 

       $current_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");

       $current_category = tep_db_fetch_array($current_category_query);

 

       if ($last_category['parent_id'] == $current_category['parent_id']) {

         for ($i = 0, $n = sizeof($cPath_array) - 1; $i < $n; $i++) {

           $cPath_new .= '_' . $cPath_array[$i];

         }

       } else {

         for ($i = 0, $n = sizeof($cPath_array); $i < $n; $i++) {

           $cPath_new .= '_' . $cPath_array[$i];

         }

       }

 

       $cPath_new .= '_' . $current_category_id;

 

       if (substr($cPath_new, 0, 1) == '_') {

         $cPath_new = substr($cPath_new, 1);

       }

     }

   }

 

   return 'cPath=' . $cPath_new;

 }

 

 function tep_get_all_get_params($exclude_array = '') {

   global $HTTP_GET_VARS;

 

   if ($exclude_array == '') $exclude_array = array();

 

   $get_url = '';

 

   reset($HTTP_GET_VARS);

   while (list($key, $value) = each($HTTP_GET_VARS)) {

     if (($key != tep_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array))) $get_url .= $key . '=' . $value . '&';

   }

 

   return $get_url;

 }

 

 function tep_date_long($raw_date) {

   if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false;

 

   $year = (int)substr($raw_date, 0, 4);

   $month = (int)substr($raw_date, 5, 2);

   $day = (int)substr($raw_date, 8, 2);

   $hour = (int)substr($raw_date, 11, 2);

   $minute = (int)substr($raw_date, 14, 2);

   $second = (int)substr($raw_date, 17, 2);

 

   return strftime(DATE_FORMAT_LONG, mktime($hour, $minute, $second, $month, $day, $year));

 }

 

////

// Output a raw date string in the selected locale date format

// $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS

// NOTE: Includes a workaround for dates before 01/01/1970 that fail on windows servers

 function tep_date_short($raw_date) {

   if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false;

 

   $year = substr($raw_date, 0, 4);

   $month = (int)substr($raw_date, 5, 2);

   $day = (int)substr($raw_date, 8, 2);

   $hour = (int)substr($raw_date, 11, 2);

   $minute = (int)substr($raw_date, 14, 2);

   $second = (int)substr($raw_date, 17, 2);

 

   if (@date('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) {

     return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));

   } else {

     return ereg_replace('2037' . '$', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037)));

   }

 

 }

 

 function tep_datetime_short($raw_datetime) {

   if ( ($raw_datetime == '0000-00-00 00:00:00') || ($raw_datetime == '') ) return false;

 

   $year = (int)substr($raw_datetime, 0, 4);

   $month = (int)substr($raw_datetime, 5, 2);

   $day = (int)substr($raw_datetime, 8, 2);

   $hour = (int)substr($raw_datetime, 11, 2);

   $minute = (int)substr($raw_datetime, 14, 2);

   $second = (int)substr($raw_datetime, 17, 2);

 

   return strftime(DATE_TIME_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));

 }

 

 function tep_get_category_tree($parent_id = '0', $spacing = '', $exclude = '', $category_tree_array = '', $include_itself = false) {

   global $languages_id;

 

   if (!is_array($category_tree_array)) $category_tree_array = array();

   if ( (sizeof($category_tree_array) < 1) && ($exclude != '0') ) $category_tree_array[] = array('id' => '0', 'text' => TEXT_TOP);

 

   if ($include_itself) {

     $category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.language_id = '" . (int)$languages_id . "' and cd.categories_id = '" . (int)$parent_id . "'");

     $category = tep_db_fetch_array($category_query);

     $category_tree_array[] = array('id' => $parent_id, 'text' => $category['categories_name']);

   }

 

   $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and c.parent_id = '" . (int)$parent_id . "' order by c.sort_order, cd.categories_name");

   while ($categories = tep_db_fetch_array($categories_query)) {

     if ($exclude != $categories['categories_id']) $category_tree_array[] = array('id' => $categories['categories_id'], 'text' => $spacing . $categories['categories_name']);

     $category_tree_array = tep_get_category_tree($categories['categories_id'], $spacing . '   ', $exclude, $category_tree_array);

   }

 

   return $category_tree_array;

 }

 

 function tep_draw_products_pull_down($name, $parameters = '', $exclude = '') {

   global $currencies, $languages_id;

 

   if ($exclude == '') {

     $exclude = array();

   }

 

   $select_string = '<select name="' . $name . '"';

 

   if ($parameters) {

     $select_string .= ' ' . $parameters;

   }

 

   $select_string .= '>';

 

   $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by products_name");

   while ($products = tep_db_fetch_array($products_query)) {

     if (!in_array($products['products_id'], $exclude)) {

       $select_string .= '<option value="' . $products['products_id'] . '">' . $products['products_name'] . ' (' . $currencies->format($products['products_price']) . ')</option>';

     }

   }

 

   $select_string .= '</select>';

 

   return $select_string;

 }

 

 function tep_options_name($options_id) {

   global $languages_id;

 

   $options = tep_db_query("select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$options_id . "' and language_id = '" . (int)$languages_id . "'");

   $options_values = tep_db_fetch_array($options);

 

   return $options_values['products_options_name'];

 }

 

 function tep_values_name($values_id) {

   global $languages_id;

 

   $values = tep_db_query("select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$values_id . "' and language_id = '" . (int)$languages_id . "'");

   $values_values = tep_db_fetch_array($values);

 

   return $values_values['products_options_values_name'];

 }

 

 function tep_info_image($image, $alt, $width = '', $height = '') {

   if (tep_not_null($image) && (file_exists(DIR_FS_CATALOG_IMAGES . $image)) ) {

     $image = tep_image(DIR_WS_CATALOG_IMAGES . $image, $alt, $width, $height);

   } else {

     $image = TEXT_IMAGE_NONEXISTENT;

   }

 

   return $image;

 }

 

 function tep_break_string($string, $len, $break_char = '-') {

   $l = 0;

   $output = '';

   for ($i=0, $n=strlen($string); $i<$n; $i++) {

     $char = substr($string, $i, 1);

     if ($char != ' ') {

       $l++;

     } else {

       $l = 0;

     }

     if ($l > $len) {

       $l = 1;

       $output .= $break_char;

     }

     $output .= $char;

   }

 

   return $output;

 }

 

 function tep_get_country_name($country_id) {

   $country_query = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$country_id . "'");

 

   if (!tep_db_num_rows($country_query)) {

     return $country_id;

   } else {

     $country = tep_db_fetch_array($country_query);

     return $country['countries_name'];

   }

 }

 

 function tep_get_zone_name($country_id, $zone_id, $default_zone) {

   $zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' and zone_id = '" . (int)$zone_id . "'");

   if (tep_db_num_rows($zone_query)) {

     $zone = tep_db_fetch_array($zone_query);

     return $zone['zone_name'];

   } else {

     return $default_zone;

   }

 }

 

 function tep_not_null($value) {

   if (is_array($value)) {

     if (sizeof($value) > 0) {

       return true;

     } else {

       return false;

     }

   } else {

     if ( (is_string($value) || is_int($value)) && ($value != '') && ($value != 'NULL') && (strlen(trim($value)) > 0)) {

       return true;

     } else {

       return false;

     }

   }

 }

 

 function tep_browser_detect($component) {

   global $HTTP_USER_AGENT;

 

   return stristr($HTTP_USER_AGENT, $component);

 }

 

 function tep_tax_classes_pull_down($parameters, $selected = '') {

   $select_string = '<select ' . $parameters . '>';

   $classes_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");

   while ($classes = tep_db_fetch_array($classes_query)) {

     $select_string .= '<option value="' . $classes['tax_class_id'] . '"';

     if ($selected == $classes['tax_class_id']) $select_string .= ' SELECTED';

     $select_string .= '>' . $classes['tax_class_title'] . '</option>';

   }

   $select_string .= '</select>';

 

   return $select_string;

 }

 

 function tep_geo_zones_pull_down($parameters, $selected = '') {

   $select_string = '<select ' . $parameters . '>';

   $zones_query = tep_db_query("select geo_zone_id, geo_zone_name from " . TABLE_GEO_ZONES . " order by geo_zone_name");

   while ($zones = tep_db_fetch_array($zones_query)) {

     $select_string .= '<option value="' . $zones['geo_zone_id'] . '"';

     if ($selected == $zones['geo_zone_id']) $select_string .= ' SELECTED';

     $select_string .= '>' . $zones['geo_zone_name'] . '</option>';

   }

   $select_string .= '</select>';

 

   return $select_string;

 }

 

 function tep_get_geo_zone_name($geo_zone_id) {

   $zones_query = tep_db_query("select geo_zone_name from " . TABLE_GEO_ZONES . " where geo_zone_id = '" . (int)$geo_zone_id . "'");

 

   if (!tep_db_num_rows($zones_query)) {

     $geo_zone_name = $geo_zone_id;

   } else {

     $zones = tep_db_fetch_array($zones_query);

     $geo_zone_name = $zones['geo_zone_name'];

   }

 

   return $geo_zone_name;

 }

 

 function tep_address_format($address_format_id, $address, $html, $boln, $eoln) {

   $address_format_query = tep_db_query("select address_format as format from " . TABLE_ADDRESS_FORMAT . " where address_format_id = '" . (int)$address_format_id . "'");

   $address_format = tep_db_fetch_array($address_format_query);

 

   $company = tep_output_string_protected($address['company']);

   if (isset($address['firstname']) && tep_not_null($address['firstname'])) {

     $firstname = tep_output_string_protected($address['firstname']);

     $lastname = tep_output_string_protected($address['lastname']);

   } elseif (isset($address['name']) && tep_not_null($address['name'])) {

     $firstname = tep_output_string_protected($address['name']);

     $lastname = '';

   } else {

     $firstname = '';

     $lastname = '';

   }

   $street = tep_output_string_protected($address['street_address']);

   $suburb = tep_output_string_protected($address['suburb']);

   $city = tep_output_string_protected($address['city']);

   $state = tep_output_string_protected($address['state']);

   if (isset($address['country_id']) && tep_not_null($address['country_id'])) {

     $country = tep_get_country_name($address['country_id']);

 

     if (isset($address['zone_id']) && tep_not_null($address['zone_id'])) {

       $state = tep_get_zone_code($address['country_id'], $address['zone_id'], $state);

     }

   } elseif (isset($address['country']) && tep_not_null($address['country'])) {

     $country = tep_output_string_protected($address['country']);

   } else {

     $country = '';

   }

   $postcode = tep_output_string_protected($address['postcode']);

   $zip = $postcode;

 

   if ($html) {

// HTML Mode

     $HR = '<hr>';

     $hr = '<hr>';

     if ( ($boln == '') && ($eoln == "\n") ) { // Values not specified, use rational defaults

       $CR = '<br>';

       $cr = '<br>';

       $eoln = $cr;

     } else { // Use values supplied

       $CR = $eoln . $boln;

       $cr = $CR;

     }

   } else {

// Text Mode

     $CR = $eoln;

     $cr = $CR;

     $HR = '----------------------------------------';

     $hr = '----------------------------------------';

   }

 

   $statecomma = '';

   $streets = $street;

   if ($suburb != '') $streets = $street . $cr . $suburb;

   if ($country == '') $country = tep_output_string_protected($address['country']);

   if ($state != '') $statecomma = $state . ', ';

 

   $fmt = $address_format['format'];

   eval("\$address = \"$fmt\";");

 

   if ( (ACCOUNT_COMPANY == 'true') && (tep_not_null($company)) ) {

     $address = $company . $cr . $address;

   }

 

   return $address;

 }

 

 ////////////////////////////////////////////////////////////////////////////////////////////////

 //

 // Function    : tep_get_zone_code

 //

 // Arguments   : country           country code string

 //               zone              state/province zone_id

 //               def_state         default string if zone==0

 //

 // Return      : state_prov_code   state/province code

 //

 // Description : Function to retrieve the state/province code (as in FL for Florida etc)

 //

 ////////////////////////////////////////////////////////////////////////////////////////////////

 function tep_get_zone_code($country, $zone, $def_state) {

 

   $state_prov_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and zone_id = '" . (int)$zone . "'");

 

   if (!tep_db_num_rows($state_prov_query)) {

     $state_prov_code = $def_state;

   }

   else {

     $state_prov_values = tep_db_fetch_array($state_prov_query);

     $state_prov_code = $state_prov_values['zone_code'];

   }

   

   return $state_prov_code;

 }

 

 function tep_get_uprid($prid, $params) {

   $uprid = $prid;

   if ( (is_array($params)) && (!strstr($prid, '{')) ) {

     while (list($option, $value) = each($params)) {

       $uprid = $uprid . '{' . $option . '}' . $value;

     }

   }

 

   return $uprid;

 }

 

 function tep_get_prid($uprid) {

   $pieces = explode('{', $uprid);

 

   return $pieces[0];

 }

 

 function tep_get_languages() {

   $languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order");

   while ($languages = tep_db_fetch_array($languages_query)) {

     $languages_array[] = array('id' => $languages['languages_id'],

                                'name' => $languages['name'],

                                'code' => $languages['code'],

                                'image' => $languages['image'],

                                'directory' => $languages['directory']);

   }

 

   return $languages_array;

 }

 

 function tep_get_category_name($category_id, $language_id) {

   $category_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$category_id . "' and language_id = '" . (int)$language_id . "'");

   $category = tep_db_fetch_array($category_query);

 

   return $category['categories_name'];

 }

 

 function tep_get_orders_status_name($orders_status_id, $language_id = '') {

   global $languages_id;

 

   if (!$language_id) $language_id = $languages_id;

   $orders_status_query = tep_db_query("select orders_status_name from " . TABLE_ORDERS_STATUS . " where orders_status_id = '" . (int)$orders_status_id . "' and language_id = '" . (int)$language_id . "'");

   $orders_status = tep_db_fetch_array($orders_status_query);

 

   return $orders_status['orders_status_name'];

 }

 

 function tep_get_orders_status() {

   global $languages_id;

 

   $orders_status_array = array();

   $orders_status_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "' order by orders_status_id");

   while ($orders_status = tep_db_fetch_array($orders_status_query)) {

     $orders_status_array[] = array('id' => $orders_status['orders_status_id'],

                                    'text' => $orders_status['orders_status_name']);

   }

 

   return $orders_status_array;

 }

 

 function tep_get_products_name($product_id, $language_id = 0) {

   global $languages_id;

 

   if ($language_id == 0) $language_id = $languages_id;

   $product_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");

   $product = tep_db_fetch_array($product_query);

 

   return $product['products_name'];

 }

 

 function tep_get_products_description($product_id, $language_id) {

   $product_query = tep_db_query("select products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");

   $product = tep_db_fetch_array($product_query);

 

   return $product['products_description'];

 }

 

 function tep_get_products_url($product_id, $language_id) {

   $product_query = tep_db_query("select products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");

   $product = tep_db_fetch_array($product_query);

 

   return $product['products_url'];

 }

 

////

// Return the manufacturers URL in the needed language

// TABLES: manufacturers_info

 function tep_get_manufacturer_url($manufacturer_id, $language_id) {

   $manufacturer_query = tep_db_query("select manufacturers_url from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . (int)$manufacturer_id . "' and languages_id = '" . (int)$language_id . "'");

   $manufacturer = tep_db_fetch_array($manufacturer_query);

 

   return $manufacturer['manufacturers_url'];

 }

 

////

// Wrapper for c

Share this post


Link to post
Share on other sites
Well Dave... I have double checked... All code is inserted, I still get the same error here are my files and lines of code;

My Admin/Modules.php

 

Ummmm, errrr.. Nevermind, boy I feel like an idiot. I knew I had set my config with my zip code, but I just checked... wasn't there.. now mod seams to work.. EXCEPT for the icon. I checked and icon is in images/icons. I'll probably find some stupid thing wrong there too..

 

TIP " Never modify code when suffering from sleep deprivation"

 

Thanks for your help Dave.

Share this post


Link to post
Share on other sites

Jim,

 

Be sure the path and name for the icon are correct...

/catalog/images/icons/shipping_usps.gif

 

Question, do you have another shipping method? i.e. UPS, FedEx, Free Shipping? If you do, are those icons showing up for you?

 

When I downloaded this mod, I did not use the supplied icon because I had one already. I just checked the downloaded package, and I found no usps icon there, so the one I am using was already on my site. Let me know what you have.

 

Dave


I am a little pencil in the hand of a writing God who is sending a love letter to the world.

--Mother Teresa

Share this post


Link to post
Share on other sites
Jim,

 

Be sure the path and name for the icon are correct...

/catalog/images/icons/shipping_usps.gif

 

Question, do you have another shipping method? i.e. UPS, FedEx, Free Shipping? If you do, are those icons showing up for you?

 

When I downloaded this mod, I did not use the supplied icon because I had one already. I just checked the downloaded package, and I found no usps icon there, so the one I am using was already on my site. Let me know what you have.

 

Dave

When I click properties it is showing two // before catalog, where do I chang that link?

Share this post


Link to post
Share on other sites

I'm a little confused. I am about to install this contribution. Yet, there is a 25 Apr 2005 update. Only thing in this update is another usps.php file. Does this replace the one in:

catalog/includes/modules/shipping/usps.php

or

catalog/includes/languages/english/modules/shipping/usps.php

 

Much appreciate any help,

David


Anthony David

AllThingsTrendy.com

Share this post


Link to post
Share on other sites

I figured it out! no need for any replies. This is an awsome contribution and fixes many issues for my lil' store!

 

Thank a $1M (if I had it).

Edited by AllThingsTrendy

Anthony David

AllThingsTrendy.com

Share this post


Link to post
Share on other sites

Hello,

I'm feeling a little frustrated here. There seem to be very frequent errors in the documentation for OsCommerce, including this contribution. While I realize that this code is being given away for free, it isn't really free is it. We have to put in the time and effort to learn a do for ourselves right. That's why it's a community not a corporation. Having said that rant. The errors I find with the instructions are

STEP 5

------

 

Replace admin/modules.php with the file included in this contribution.  Do this

even if you have used versions of USPS Methods.

and in step six as well. The problem there was no modules.php included in the contribution down load. If there was a problem with those files and the were deleted and then we are expected to edit the code only. Why weren't the instructions updated along with the removal of the files from the contribution. Any one know if this contribution works? If so what is the proper proceedure?

On your last day only you will have to approve or disaprove of how your life has been.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×