Jump to content
bad_lemming

[Contribution] - USPS Methods

Recommended Posts

Have instaled both the 4.2.1 and 4.3.

 

Deinstalled and reinstalled and edited the admin options.

 

In 4.3 entered user name and pw and they were replaced with the word array after update.

 

In 4.2.1 ticked various option and after update this is displayed.

 

 

USPS Options

Array

 

Domestic Insurance Options

None

 

International Insurance Options

None

 

Domestic Shipping Methods

Array

 

Int'l Shipping Methods

Array

 

Can't find anything yet in the forum but will keep looking.

 

Any thoughts?

 

you missed the insert into general.php

Scott

Share this post


Link to post
Share on other sites
you missed the insert into general.php

Scott

 

If only, just went back & checked. Removed 2 functions I believe came from 4.3 as currently trying 4.2.1

 

Will go back and check installation again.

 

////
// Alias function for module configuration keys
 function tep_mod_select_option($select_array, $key_name, $key_value) {
reset($select_array);
while (list($key, $value) = each($select_array)) {
  if (is_int($key)) $key = $value;
  $string .= '<br><input type="radio" name="configuration[' . $key_name . ']" value="' . $key . '"';
  if ($key_value == $key) $string .= ' CHECKED';
  $string .= '> ' . $value;
}

return $string;
 }
// USPS Methods 3.0
// 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++) {
  $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 .= '> ' . $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.
// Creates multiple text input boxes in a list.
// Remember to add blank default values: 1, 2, , , 5, 6, ...
 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.  Added by Greg Deeth
// Alias function for Store configuration values in the Administration Tool.
// Creates a text input box on either side of the option, adds <= OPTION <= and makes a list.
// Remember to add blank default values: 1, 2, , , 5, 6, ...
 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;
 }

*/

////
// Retreive server information
 function tep_get_system_information() {
global $HTTP_SERVER_VARS;

Edited by geoffreywalton

Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Share this post


Link to post
Share on other sites

sorry this is the step you missed:

 

catalog/admin/modules.php

*****************************************
Find This code somewhere around line 43:
*****************************************

if (tep_not_null($action)) {
switch ($action) {
  case 'save':
	while (list($key, $value) = each($HTTP_POST_VARS['configuration'])) {

***********************************************
INSERT THE FOLLOWING CODE AFTER THE ABOVE LINE:
***********************************************

	  if( is_array( $value ) ){
	  $value = implode( ", ", $value);
	  $value = ereg_replace (", --none--", "", $value);
		}

****************************
SO IT SHOULD LOOK LIKE THIS:
****************************

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);
		}
	  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':

 

Scott

Share this post


Link to post
Share on other sites

I am now having the same problem for both domestic and international rates.

 

lildog

 

I have installed v. 3.0.2 and updated my database but I can't seem to get this addon to work for me. So I decided to give v. 4.3.0 ALPHA a shot, and I still have the same error:

 

United States Postal Service 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

 

I've been searching for an answer and so far found that one other person has the same error I have. Can someone point me towards the direction I need to go so I can get this contribution to work? Thanks.

Share this post


Link to post
Share on other sites
I am now having the same problem for both domestic and international rates.

 

lildog

 

Unfortunately, almost every time you get that error, it will be the USPS servers' fault rather than the addon's fault (domestic shipping only). There is an exception. I know that USPS changed their text definitions for international shipments in the API; however, no addon has been updated yet to support the changed shipping definitions that I'm aware of...

 

Scott

Edited by olsonsp4c

Share this post


Link to post
Share on other sites

Just came back after checking every step and how right you are!!!

 

Thanks just needed some one to take me off my pedastal.

 

G

 

Debug steps.

 

Check you followed all of the installation instructions ( this was he one I missed)

Check Shipping zip code set up in the admin for shipping options.

Check the USPS user name and password entered in module settings?

Did you de-install and then re-install the module if you are upgrading?

Is the destination zip code valid?

Have you ticked some shipping methods that are valid between the shop zip code and the destination.

 

You can edit the usps.php code to send you an email with usps error message or dump it to the screen

 

if ($http->Get('/' . $api_dll . '?' . $request)) $body = $http->getBody();

// mail('osc@theukwaltons.co.uk','USPS rate quote response',$body,'From: <sales@theukwaltons.co.uk>');

if ($transit && is_array($transreq) && ($order->delivery['country']['id'] == STORE_COUNTRY)) {

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

if ($http->Get('/' . $api_dll . '?' . $value)) $transresp[$key] = $http->getBody();

}

}

 

$http->Disconnect();

 

} else {

return false;

}

//var_dump(htmlspecialchars($body, ENT_QUOTES));


Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Share this post


Link to post
Share on other sites

Moved to 4.0.3 Alpha and international works now but same error for domestic.

 

lildog

 

I am now having the same problem for both domestic and international rates.

 

lildog

Share this post


Link to post
Share on other sites

When I drop the default usps module back in it works.

 

lildog

 

Unfortunately, almost every time you get that error, it will be the USPS servers' fault rather than the addon's fault (domestic shipping only). There is an exception. I know that USPS changed their text definitions for international shipments in the API; however, no addon has been updated yet to support the changed shipping definitions that I'm aware of...

 

Scott

Share this post


Link to post
Share on other sites

mmmm....I checked all of the domestic methods and it works. and turned wight and transit times on.

 

 

When I drop the default usps module back in it works.

 

lildog

Edited by lildog

Share this post


Link to post
Share on other sites
When I drop the default usps module back in it works.

 

lildog

 

which one, the osC rc2a version or methods 3.0.2?

Share this post


Link to post
Share on other sites

Ok it works. I do not know what the glitch was.

For those that get:

United States Postal Service 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

 

I turned all shipping options on and turned display transit times and weights on. Did a test check out to the shipping page, with an account that has both a domestic address and a international address. Tries both addresses. Went back and turned off the options one at a time. No more error. I am using OSC2.2rc2a and USPS Methods 4.0.3 Alpha

 

lildog

 

PS( Maybe a cookie, sessionid, cache problem? I do not know)

 

 

which one, the osC rc2a version or methods 3.0.2?

Share this post


Link to post
Share on other sites

This is request...not a bug. Where would I look in usps module to add an alert to international customers that there may be problems selecting shipping and to contact the shop owner if needed. I can't for the life of me spot where to put it.

 

lildog

 

which one, the osC rc2a version or methods 3.0.2?

Share this post


Link to post
Share on other sites
This is request...not a bug. Where would I look in usps module to add an alert to international customers that there may be problems selecting shipping and to contact the shop owner if needed. I can't for the life of me spot where to put it.

 

lildog

 

I've put warnings like this in the catalog/includes/languages/english/checkout_shipping.php at the end of this line:

 

define('TEXT_CHOOSE_SHIPPING_METHOD', 'Please select the preferred shipping method to use on this order.');

 

I change it to something like this:

 

define('TEXT_CHOOSE_SHIPPING_METHOD', 'Please select the preferred shipping method to use on this order.<br><br>If you have ordered using International shippping...');

 

Scott

Share this post


Link to post
Share on other sites

THANK YOU SCOTT FOR POINTING ME IN THE CORRECT DIRECTION.

I found another way and was just coming back to post it. This only shows now for International Orders.

 

FIND:

$radio_buttons = 0;

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

 

ADD BEFORE:

if ($order->delivery['country_id'] != STORE_COUNTRY){

echo ALERT_INTERNATIONAL;

}

 

 

ADD in languages/english/checkout_shipping.php:

 

define('ALERT_INTERNATIONAL','<font color="red"><center><b>Alert message</b></center></font><br>We have had known issues with the postage calculations for International orders. If you are being charged <b>Global Express Guaranteed rates</b> for your shipping and <b>have not chosen that option</b> - please contact us via email <a href="mailto:duds4buds@msn.com">duds4buds@msn.com</a> <b>Subject title:</b> International Shipping problems. We will then contact you and suggest less expensive ways of our shipping your items to you.<br><br>We are working at correcting this problem and need to be contacted if the problem reoccurs.<br>Thank you.<br><br>');

 

 

I've put warnings like this in the catalog/includes/languages/english/checkout_shipping.php at the end of this line:

 

define('TEXT_CHOOSE_SHIPPING_METHOD', 'Please select the preferred shipping method to use on this order.');

 

I change it to something like this:

 

define('TEXT_CHOOSE_SHIPPING_METHOD', 'Please select the preferred shipping method to use on this order.<br><br>If you have ordered using International shippping...');

 

Scott

Share this post


Link to post
Share on other sites

I have just installed USPS Methods 3.0.2. Everything seems to work smoothly, except the prices.

 

First, I have decimalized both the weights and the tare. I have set my zip, but the problem is first class, and that is the same price nationwide anyway. Aside from my problem, is decimalized pounds the only method? I saw a few incomplete references to solutions. Is there a proper place to insert $shippingweight*.0625 so that I can enter ounces? Is there a place to replace (whatever, 'lbs') to (whatever, 'ozs') as a smoother solution? Is there a method people use other than decimalizing my weights in an excel sheet?

 

Mainly, the weights reflect accurately with my decimalized pounds. The price returned at that weight seems to be one ounce and one penny below the commercial rates I pay through Endicia. I seem to remember when the postal rates went up, it went up about an ounce and a penny. That makes it look to me like I am seening the old rates. Is that even possible? I get

4oz United States Postal Service First Class Mail: Estimated 1 - 5 Days $1.68 , but I pay $1.86 for 4oz. I pay $1.69 for 3oz.

8oz United States Postal Service First Class Mail: Estimated 1 - 5 Days $2.36 , but I pay $2.54 for 8oz. I pay $2.37 for 7oz.

It's off by an ounce and a penny, consistantly.

 

Thirdly, it appears the insurance settings are mandatory (True), or prohibitted (False). Is there a way to make insurance optional?

 

Thanks,

Walter


My experience relates to osCommerce Online Merchant v2.2 RC2

Share this post


Link to post
Share on other sites

I'm getting enormous amount of emails with 'USPS rate quote response' in the subject, like the one below:

<?xml version="1.0"?>
<Error><Number>-2147219099</Number><Source>Rate_Respond.:clsRateV3.UnpackRateNode;SOLServerRates.RateV3_Respond</Source><Description>Missing value for ZipDestination.</Description><HelpFile></HelpFile><HelpContext>1000440</HelpContext></Error>

Can someone please explain me what they mean and why am I getting them?

 

Thanks in advance.

Share this post


Link to post
Share on other sites

[bUG AND PATCH]

 

I noticed a problem with the sql generated for the installation. The stock oscommerce configuration table can only hold up to 255 characters in the set_function field, however the MODULE_SHIPPING_USPS_TYPES_INTL configuration option has it longer than that. This leads to the set_function value being truncated, and an error shows up on the /admin/modules.php?set=shipping&module=usps&action=edit page when you attempt to edit the USPS module settings. The error text is:

Parse error: syntax error, unexpected T_GLOBAL, expecting ')' in /var/www/mysite/osc/admin/modules.php(218) : eval()'d code on line 1

 

and makes it impossible to select which international shipping methods you want available. The solution is to run the following code in mysql console:

 

alter table configuration change configuration_value configuration_value text;

alter table configuration change set_function set_function text;

update configuration SET set_function = "tep_cfg_select_multioption(array('GLOBAL EXPRESS', 'GLOBAL EXPRESS NON-DOC RECT', 'GLOBAL EXPRESS NON-DOC NON-RECT', 'EXPRESS MAIL INT', 'EXPRESS MAIL INT FLAT RATE ENV', 'PRIORITY MAIL INT', 'PRIORITY MAIL INT FLAT RATE ENV', 'PRIORITY MAIL INT FLAT RATE BOX', 'FIRST-CLASS MAIL INT'), " WHERE configuration_key = 'MODULE_SHIPPING_USPS_TYPES_INTL';

 

This changes the configuration_value and set_function fields to be text fields, which has a much larger length limit, and resets the set_function field to the correct un-truncated value.

 

This might or might not help with some of the international shipping problems, but at least it makes it possible to choose which options you want to show. You can now go to the shipping modules page and edit which international shipping options you want the customer to see.

Edited by aeontech

Share this post


Link to post
Share on other sites

I am currently using version 3.0.2 and have the problem where my international customers are having to use GLOBAL EXPRESS because it will not let them select the other usps shipping options. Is there a fix to this or has this been resolved with the newer versions available for this contribution?

 

I really need an answer to this real soon or I will lose my international customer base...

Share this post


Link to post
Share on other sites

I don't think this contribution is working at all. I just installed the 3.0.2 version over the original OSCommerece version and I didn everything the isntallation file asked me to do but no matte what I do I still keep getting the error

 

United States Postal Service 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

 

and I'm already using the production server too.

Share this post


Link to post
Share on other sites
I don't think this contribution is working at all. I just installed the 3.0.2 version over the original OSCommerece version and I didn everything the isntallation file asked me to do but no matte what I do I still keep getting the error

 

United States Postal Service 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

 

and I'm already using the production server too.

 

I tried to install 3.4.0 Alpha now and I'm getting this error

 

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

 

Anyone know what it means?

Edited by RiseAgainst

Share this post


Link to post
Share on other sites

Hi Victor,

I had both problems with both versions myself. Emphasis on "I"...

 

1) The server info (test server) and API from USPS was different than that in v3~. Plus I was waiting for the production access.

 

While waiting, I decided to go to v4~.

 

2) In my haste I missed an edit. Fixed. I phoned USPS and was granted access to the production server.

 

All is well now.

Share this post


Link to post
Share on other sites

okay, i installed my ENTIRE os commerce store with no problems whatsoever....and i just installed USPS methods. now, it seems to be working great except for one thing- no matter how many items are in my cart, the weight and shipping price stays the same. eg: one item weighs 0.3 lbs. and the shipping is $7.31. after i add another item to the cart that weighs 2.3 lbs (on top of the o.3 lbs.) the shipping price and weight remain the same. i fixed the tare weight so that can't be the problem. i am really anxious to open this new store and i just need to fix this minor problem before i can. should i edit the usps.php code to "oz." instead of "pounds"? please help!!

Share this post


Link to post
Share on other sites

Check in the shipping options for tare wt.

 

Bet it is set to 3.


Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Share this post


Link to post
Share on other sites

Hi there.

Please help! Installed 4.3.0 Alpha version and am having problems and don't know what went wrong...

I followed instructions, got USPS to activate my account and installed module. Even though instructions say I didn't need to do these steps since I am installing v.4.3.0 or higher, it wouldn't work unless I modified the two files catalog/includes/functions/general.php & catalog/admin/includes/functions/general.php. So I did as instructed. After that, I was able to install the module and it showed all the options fine. But after saving my edits (ie. added my id/pw and checked/unchecked options), the resulting information summary showed "Array" on most of the options, and I get error message when testing a live purchase from the site, "An error occured with the USPS shipping calculations. If you prefer to use USPS as your shipping method, please contact the store owner." I really don't know what I am doing wrong. Can someone please help me understand and fix my "Array" problem?

Share this post


Link to post
Share on other sites

Hello,

I'm not sure if something changed with USPS recently, however First Class Mail no long shows up to my customers. I checked the Admin section, and it is selected as a choice that should be displayed to customers, however it never shows up.

I don't remember making any new modifications to the module, I'm using V3.0.2., but I know it used to work just fine. Does anyone have any ideas what may have changed recently to make First Class Mail no longer show, or even butter, what needs to happen to make it show?

 

// I added the dash in First-Class Mail

$this->types = array('EXPRESS' => 'Express Mail',

'FIRST CLASS' => 'First-Class Mail',

'PRIORITY' => 'Priority Mail',

'PARCEL' => 'Parcel Post',

'BPM' => 'Bound Printed Matter',

'MEDIA' => 'Media Mail');

 

When i noticed the problem I added the - in the above code but That didn't do anything. Is there some other place I need to check to make sure it's named right so USPS sends the quote?

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

×