Updating your USPS Shipping Module (November 21, 2007)
The problem: When a customer tries to select a USPS shipping option that is not the first one on the list, the store defaults it back to the first one on the list on the confirmation page making it impossible for the customer to choose a shipping option.

The reason: USPS changed their shipping API on November 18, 2007 to require all items to be sent in uppercase instead of the old format, first character uppercase and the rest lowercase.

The solution: Follow the following steps to update your USPS Shipping module to work with the changes to the USPS made to their api on November 18th 2007. Some advanced knowledge of FTP will be required. This is a self-help tutorial and no support is provided with this.

If you would like Web Your Business, Inc to perform the updates on your website, please email clientdata@webyourbusiness.com and request a quote for the 'USPS Shipping Module Update on November 18th, 2007'

I.         Open the file   includes/modules/shipping/usps.php

A.      Near line 47 find:

$this->types = array('Express' => 'EXPRESS',
     'First Class' => 'First-Class Mail',
     'Priority' => 'Priority',
     'Parcel' => 'Parcel');


Replace with:

$this->types = array('EXPRESS' => 'EXPRESS',
     'FIRST CLASS' => 'First-Class Mail',
     'PRIORITY' => 'Priority',
     'PARCEL' => 'Parcel');

B.      Near line 147 find:

tep_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Domestic Shipping Methods', 'MODULE_SHIPPING_USPS_TYPES', 'Express, Priority, First Class, Parcel', 'Select the domestic services to be offered:', '6', '14', 'tep_cfg_select_multioption(array(\'Express\', \'Priority\', \'First Class\', \'Parcel\'), ', now())");

Replace with:

tep_db_query("insert into " . TABLE_CONFIGURATION . " ( configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Domestic Shipping Methods', 'MODULE_SHIPPING_USPS_TYPES', 'EXPRESS, PRIORITY, FIRST CLASS, PARCEL', 'Select the domestic services to be offered:', '6', '14', 'tep_cfg_select_multioption(array(\'EXPRESS\', \'PRIORITY\', \'FIRST CLASS\', \'PARCEL\'), ', now())");

C.      Near line 222 find:

switch ($key) {
   case 'Express': $transreq[$key] = 'API=ExpressMail&XML=' .
      urlencode( '');
      break;
   case 'Priority': $transreq[$key] = 'API=PriorityMail&XML=' .
      urlencode( '');
      break;
   case 'Parcel': $transreq[$key] = 'API=StandardB&XML=' .
      urlencode( '');
      break;
   default: $transreq[$key] = '';
      break;
}


Replace with:

switch ($key) {
   case 'EXPRESS': $transreq[$key] = 'API=ExpressMail&XML=' .
      urlencode( '');
      break;
   case 'PRIORITY': $transreq[$key] = 'API=PriorityMail&XML=' .
      urlencode( '');
      break;
   case 'PARCEL': $transreq[$key] = 'API=StandardB&XML=' .
      urlencode( '');
      break;
   default: $transreq[$key] = '';
      break;
}

C.      Near line 322 find:

switch ($service) {
  case 'Express': $time = ereg('(.*)', $transresp[$service], $tregs);
      $time = $tregs[1];
      if ($time == '' || $time == 'No Data') {
        $time = '1 - 2 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
      } else {
        $time = 'Tomorrow by ' . $time;
      }
      break;
  case 'Priority': $time = ereg('(.*)', $transresp[$service], $tregs);
      $time = $tregs[1];
      if ($time == '' || $time == 'No Data') {
        $time = '2 - 3 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
      } elseif ($time == '1') {
        $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAY;
      } else {
        $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
      }
      break;
  case 'Parcel': $time = ereg('(.*)', $transresp[$service], $tregs);
      $time = $tregs[1];
      if ($time == '' || $time == 'No Data') {
        $time = '4 - 7 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
      } elseif ($time == '1') {
        $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAY;
      } else {
        $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
      }
      break;
  case 'First Class': $time = '2 - 5 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
      break;
  default: $time = '';
      break;
}


Replace with:

switch ($service) {
  case 'EXPRESS': $time = ereg('(.*)', $transresp[$service], $tregs);
      $time = $tregs[1];
      if ($time == '' || $time == 'No Data') {
        $time = '1 - 2 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
      } else {
        $time = 'Tomorrow by ' . $time;
      }
      break;
  case 'PRIORITY': $time = ereg('(.*)', $transresp[$service], $tregs);
      $time = $tregs[1];
      if ($time == '' || $time == 'No Data') {
        $time = '2 - 3 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
      } elseif ($time == '1') {
        $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAY;
      } else {
        $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
      }
      break;
  case 'PARCEL': $time = ereg('(.*)', $transresp[$service], $tregs);
      $time = $tregs[1];
      if ($time == '' || $time == 'No Data') {
        $time = '4 - 7 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
      } elseif ($time == '1') {
        $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAY;
      } else {
        $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
      }
      break;
  case 'FIRST CLASS': $time = '2 - 5 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
      break;
  default: $time = '';
      break;
}

E.      In Oscommerce Administration section:

Uninstall and reinstall the USPS module for the changes to take effect.

III.     Again, this is a self-help tutorial and no support is provided with this.

If you would like Web Your Business, Inc to perform the updates on your website, please email clientdata@webyourbusiness.com and request a quote for the 'USPS Shipping Module Update on November 18th, 2007'