USPS Methods manual installation for oscommerce version 2.3.1
This is USPS Methods only for osc2.3.1 with manual installation.
Contribution Link: http://addons.oscommerce.com/info/487
Install note:
1. Uninstall USPS module from admin panel if it is installed.
2. Drop all files from catalog/ to your store/ directory.
3. Open includes/application_top.php. On line 15 replace “YOURNEARESTCITY” with the city that represents your time zone. City list can be found here: http://www.php.net/manual/en/timezones.america.php
4. From your admin panel click configuration/email options – and set “Use MIME HTML When Sending Emails” to true.
5. Install the USPS module from your admin panel and configure
General step:
Copy both files to your catalog folder.
1.includes/modules/shipping/usps.php
2.includes/languages/english/modules/shipping/usps.php
Manual Installation:
////////////////////////////////////////////////
1. checkout_shipping.php
Find:
<td width="75%" style="padding-left: 15px;"><?php echo $quotes[$i]['methods'][$j]['title']; ?></td>
Replace with:
<!-- USPS Methods osc 2.3.1 --->
<?php
$search = array(' regimark', ' tradmrk');
$replace = array('<sup>®</sup>', '<sup>™</sup>');
?>
<td width="75%" style="padding-left: 15px;"><?php echo str_replace($search, $replace, $quotes[$i]['methods'][$j]['title']); ?></td>
<!-- USPS Methods osc 2.3.1 --->2. includes/application_top.php
add this anywhere
// USPS Methods osc 2.3.1
// set default store time zone
ini_set('date.timezone', 'America/YOURNEARESTCITY');
// USPS Methods osc 2.3.1
3. includes/functions/general.php
Find:
// Wrapper function for round()
function tep_round($number, $precision) {
and add after
// USPS Methods osc 2.3.1
// Round up function for non whole numbers by GREG DEETH
// The value for the precision variable determines how many digits after the decimal and rounds the last digit up to the next value
// Precision = 0 -> xx.xxxx = x+
// Precision = 1 -> xx.xxxx = xx.+
// Precision = 2 -> xx.xxxx = xx.x+
function tep_round_up($number, $precision) {
$number_whole = '';
$num_left_dec = 0;
$num_right_dec = 0;
$num_digits = strlen($number);
$number_out = '';
$i = 0;
while ($i + 1 <= strlen($number))
{
$current_digit = substr($number, $i, ($i + 1) - $num_digits);
if ($current_digit == '.') {
$i = $num_digits + 1;
$num_left_dec = strlen($number_whole);
$num_right_dec = ($num_left_dec + 1) - $num_digits;
} else {
$number_whole = $number_whole . $current_digit;
$i = $i + 1;
}
}
if ($num_digits > 3 && $precision < ($num_digits - $num_left_dec - 1) && $precision >= 0) {
$i = $precision;
$addable = 1;
while ($i > 0) {
$addable = $addable * .1;
$i = $i - 1;
}
$number_out = substr($number, 0, $num_right_dec + $precision) + $addable;
} else {
$number_out = $number;
}
return $number_out;
}
////
// USPS Methods osc 2.3.1
4. includes/modules/order_total/ot_shipping.php
Find:
$this->output[] = array('title' => $order->info['shipping_method'] . ':',
'text' => $currencies->format($order->info['shipping_cost'], true, $order->info['currency'], $order->info['currency_value']),
'value' => $order->info['shipping_cost']);
Replace with:
// USPS Methods osc 2.3.1
/* $this->output[] = array('title' => $order->info['shipping_method'] . ':',
'text' => $currencies->format($order->info['shipping_cost'], true, $order->info['currency'], $order->info['currency_value']),
'value' => $order->info['shipping_cost']); */
$search = array(' regimark', ' tradmrk');
$replace = array('<sup>®</sup>', '<sup>™</sup>');
$this->output[] = array('title' => str_replace($search, $replace, $order->info['shipping_method']) . ':',
'text' => $currencies->format($order->info['shipping_cost'], true, $order->info['currency'], $order->info['currency_value']),
'value' => $order->info['shipping_cost']);
// USPS Methods osc 2.3.1
5. admin/includes/functions/general.php
Find this function:
// Alias function for module configuration keys
function tep_mod_select_option($select_array, $key_name, $key_value) {
reset($select_array);
Add after:
// USPS Methods osc 2.3.1
// Alias function for Store configuration values in the Administration Tool
function tep_cfg_select_multioption($select_array, $key_value, $key = '') {
for ($i=0; $i<sizeof($select_array); $i++) {
$search = array(' regimark', ' tradmrk');
$replace = array('<sup>®</sup>', '<sup>™</sup>');
$name = (($key) ? 'configuration[' . $key . '][]' : 'configuration_value');
$string .= '<br><input type="checkbox" name="' . $name . '" value="' . $select_array[$i] . '"';
$key_values = explode( ", ", $key_value);
if ( in_array($select_array[$i], $key_values)) $string .= ' CHECKED';
$string .= '> ' . str_replace($search, $replace,$select_array[$i]);
}
$string .= '<input type="hidden" name="' . $name . '" value="--none--">';
return $string;
}
// USPS Methods. Added by Greg Deeth
// Alias function for Store configuration values in the Administration Tool.
function tep_cfg_multiinput_list($select_array, $key_value, $key = '') {
$key_values = explode( ", ", $key_value);
for ($i=0; $i<sizeof($select_array); $i++) {
$name = (($key) ? 'configuration[' . $key . '][]' : 'configuration_value');
$string .= '<br><input type="text" name="' . $name . '" value="' . $key_values[$i] . '"> ' . $select_array[$i];
}
$string .= '<input type="hidden" name="' . $name . '" value="--none--">';
return $string;
}
// USPS Methods.
// Alias function for Store configuration values in the Administration Tool.
function tep_cfg_multiinput_duallist_oz($select_array, $key_value, $key = '') {
$key_values = explode( ", ", $key_value);
$string .= '<center>';
for ($i=0; $i<sizeof($select_array); $i++) {
$current_key_value = current($key_values);
$name = (($key) ? 'configuration[' . $key . '][]' : 'configuration_value');
$string .= '<br><input type="text" name="' . $name . '" size="3" value="' . $current_key_value . '"><i>oz</i>';
$string .= ' <b><</b> ' . $select_array[$i] . ' <u><b><</b></u>';
next($key_values);
$current_key_value = current($key_values);
$string .= '<input type="text" name="' . $name . '" size="3" value="' . $current_key_value . '"><i>oz</i>';
next($key_values);
}
$string .= '<input type="hidden" name="' . $name . '" value="--none--">';
$string .= '</center>';
return $string;
}
function tep_cfg_multiinput_duallist_lb($select_array, $key_value, $key = '') {
$key_values = explode( ", ", $key_value);
$string .= '<center>';
for ($i=0; $i<sizeof($select_array); $i++) {
$current_key_value = current($key_values);
$name = (($key) ? 'configuration[' . $key . '][]' : 'configuration_value');
$string .= '<br><input type="text" name="' . $name . '" size="3" value="' . $current_key_value . '"><i>lbs</i>';
$string .= ' <b><</b> ' . $select_array[$i] . ' <u><b><</b></u>';
next($key_values);
$current_key_value = current($key_values);
$string .= '<input type="text" name="' . $name . '" size="3" value="' . $current_key_value . '"><i>lbs</i>';
next($key_values);
}
$string .= '<input type="hidden" name="' . $name . '" value="--none--">';
$string .= '</center>';
return $string;
}
////
// USPS Methods osc 2.3.1
6. admin/modules.php
Find:
while (list($key, $value) = each($HTTP_POST_VARS['configuration'])) {
Add after:
// USPS Methods osc 2.3.1
if( is_array( $value ) ){
$value = implode( ", ", $value);
$value = ereg_replace (", --none--", "", $value);
}
// USPS Methods osc 2.3.1
Contribution Link: http://addons.oscommerce.com/info/487
Then install the module!
Done!





Thanks alot – your answer solved all my polrbems after several days struggling
Anyone solved the ereg() depreciated when using PHP 5.3?
Or any USPS Method version compatible with PHP 5.3??
Thanks.
cool story bro