Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] - USPS Methods


Recommended Posts

yup that's it! whatever is on the top of your list for shipping methods is all it will go to. USPS must have changed something last night. I checked a couple other OS sites and looked like they had the same thing going on.

 

Jason

 

Having the exact same problem here. To temporarily fix (until a real fix is found), we are only offering Priority shipping. That way, there is no confusion to the customer.

 

Real bad time of year for this to happen--right near christmas. We've already lost a couple of customers who did not want to pay Express shipping.

 

If anyone knows what's going on, please post!

 

Thanks!

 

JustPillows.com

Soft, elegant, yet suprisingly affordable

Link to comment
Share on other sites

I am also having the same problem. I tried running the fix in usps methods 2.9.2 upper case fix, and now it won't work at all.

 

Does anyone know how to fix that?

 

It stopped working once I ran the update.sql file contained in the zip:

 

UPDATE configuration
SET configuration_value = UPPER(configuration_value),
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';

UPDATE configuration
SET configuration_value = UPPER(configuration_value),
set_function='tep_cfg_select_multioption(array(''EXPRESS'', ''PRIORITY'', ''FIRST CLASS'', ''PARCEL'', ''BPM'', ''LIBRARY'', ''MEDIA''), '
WHERE configuration_key='MODULE_SHIPPING_USPS_TYPES'

Link to comment
Share on other sites

Here is how I fixed the problem related to usps method problems posted by Jayman11, dreamlab, ace21gabriel and justpillows. Seems the post office made changes that caused the first item listed to be selected everytime instead of the actual shipping method chosen by a customer.

 

This is just a hack, read carefully and backup your database and files before making any changes!!!!!!!!!!!!!!!

 

The root of the problem seems to be that the USPS changed the format of some of the shipping classes. I am only using USPS classes for First Class, Priority and Express mail and that is all that is outlined in this fix. You will need to modify these instructions to match your needs....

 

In the end all I had to do was change the instances of Priority to PRIORITY, First Class to FIRST CLASS and Express Mail to EXPRESS. With the exception of the types table.

 

The same values also had to be updated in the database.... Nothing like a little scrambling to ensure things are online and working for the holiday shoppers :)

 

I hope this helps others....

 

I am using the module - USPS Methods 2.5

File Changes:

I had to update the file includes/modules/shipping/usps.php

===Lines 48-50

From This:
      $this->types = array('Express' => 'Express Mail',
                           'First Class' => 'First-Class Mail',
                           'Priority' => 'Priority Mail',
To This:
      $this->types = array('EXPRESS' => 'Express Mail',
                           'FIRST CLASS' => 'First-Class Mail',
                           'PRIORITY' => 'Priority Mail',

===Lines 148

From This:
      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 ShippingMethods', '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())");

To This:
      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 ShippingMethods', '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())");

===Line 223-226

From This:
              case 'Express':  $transreq[$key] = 'API=ExpressMail&XML=' . urlencode( '<ExpressMailRequest ' . $transitreq . '</ExpressMailRequest>');
                                break;
              case 'Priority': $transreq[$key] = 'API=PriorityMail&XML=' .

To This:
              case 'EXPRESS':  $transreq[$key] = 'API=ExpressMail&XML=' . urlencode( '<ExpressMailRequest ' . $transitreq . '</ExpressMailRequest>');
                                break;
              case 'PRIORITY': $transreq[$key] = 'API=PriorityMail&XML=' .

===Line 324

 
From This:
                case 'Express':     $time = ereg('<MonFriCommitment>(.*)</MonFriCommitment>', $transresp[$service], $tregs);

To This:
                case 'EXPRESS':     $time = ereg('<MonFriCommitment>(.*)</MonFriCommitment>', $transresp[$service], $tregs);

===Line 332:

From This:
                case 'Priority':    $time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);
To This:
                case 'PRIORITY':    $time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);

===Line 352:

From This:
                case 'First Class': $time = '2 - 5 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
To This:
                case 'FIRST CLASS': $time = '2 - 5 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;

Database changes:

 

I used phpmyadmin to manually update the configuratin.

  • Selected the configuration table in the database
  • Found the entry with the following attributes:
    configuration_key = MODULE_SHIPPING_USPS_TYPES
  • For the field 'set_function I change the following values:

  • Express 'changed to' EXPRESS
  • Priority 'changed to' PRIORITY
  • First Class 'changed to' FIRST CLASS

-MichaelC

Link to comment
Share on other sites

I realized that I ran the query twice, but that shouldn't matter, should it? The file says it just changes the shipping from lower to upper case. I ran it once, it didn't seem to do anything, so I ran it again, and after that it totally stopped working and I get this:

 

An error occured with the USPS shipping calculations.

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

 

Can someone please help me?

 

I am also having the same problem. I tried running the fix in usps methods 2.9.2 upper case fix, and now it won't work at all.

 

Does anyone know how to fix that?

 

It stopped working once I ran the update.sql file contained in the zip:

 

UPDATE configuration
SET configuration_value = UPPER(configuration_value),
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';

UPDATE configuration
SET configuration_value = UPPER(configuration_value),
set_function='tep_cfg_select_multioption(array(''EXPRESS'', ''PRIORITY'', ''FIRST CLASS'', ''PARCEL'', ''BPM'', ''LIBRARY'', ''MEDIA''), '
WHERE configuration_key='MODULE_SHIPPING_USPS_TYPES'

Link to comment
Share on other sites

Hi,

 

I'm really struggling to get this contib working. I think that my database is not right. In the contribution sql query needed by bobbitodrake 3 Oct 2007 there is mention made of getting the configuration ID:

Run this code in MySQL to find out your configuration id:

 

SELECT configuration_id from configuration where configuration_key = "MODULE_SHIPPING_USPS_TYPES_INTL";

 

I don't have MODULE_SHIPPING_USPS_TYPES_INTL.

mysql> SELECT configuration_key, configuration_id from configuration WHERE configuration_key LIKE '%USPS%';
+---------------------------------+------------------+
| configuration_key			   | configuration_id |
+---------------------------------+------------------+
| MODULE_SHIPPING_USPS_SORT_ORDER |			  177 |
| MODULE_SHIPPING_USPS_ZONE	   |			  176 |
| MODULE_SHIPPING_USPS_TAX_CLASS  |			  175 |
| MODULE_SHIPPING_USPS_HANDLING   |			  174 |
| MODULE_SHIPPING_USPS_PASSWORD   |			  172 |
| MODULE_SHIPPING_USPS_SERVER	 |			  173 |
| MODULE_SHIPPING_USPS_USERID	 |			  171 |
| MODULE_SHIPPING_USPS_STATUS	 |			  170 |
+---------------------------------+------------------+
8 rows in set (0.00 sec)

 

My Admin -> Modules ->Shipping page shows3 new blank text boxes after the Sort Order entry and no description of what they are for.

 

Any suggestions?

Link to comment
Share on other sites

Thanks so much for figuring that out and posting it...it works like a charm!

 

Regards,

Heather

 

www.girlcharlee.com

 

Here is how I fixed the problem related to usps method problems posted by Jayman11, dreamlab, ace21gabriel and justpillows. Seems the post office made changes that caused the first item listed to be selected everytime instead of the actual shipping method chosen by a customer.

 

This is just a hack, read carefully and backup your database and files before making any changes!!!!!!!!!!!!!!!

 

The root of the problem seems to be that the USPS changed the format of some of the shipping classes. I am only using USPS classes for First Class, Priority and Express mail and that is all that is outlined in this fix. You will need to modify these instructions to match your needs....

 

In the end all I had to do was change the instances of Priority to PRIORITY, First Class to FIRST CLASS and Express Mail to EXPRESS. With the exception of the types table.

 

The same values also had to be updated in the database.... Nothing like a little scrambling to ensure things are online and working for the holiday shoppers :)

 

I hope this helps others....

 

I am using the module - USPS Methods 2.5

File Changes:

I had to update the file includes/modules/shipping/usps.php

===Lines 48-50

From This:
      $this->types = array('Express' => 'Express Mail',
                           'First Class' => 'First-Class Mail',
                           'Priority' => 'Priority Mail',
To This:
      $this->types = array('EXPRESS' => 'Express Mail',
                           'FIRST CLASS' => 'First-Class Mail',
                           'PRIORITY' => 'Priority Mail',

===Lines 148

From This:
      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 ShippingMethods', '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())");

To This:
      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 ShippingMethods', '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())");

===Line 223-226

From This:
              case 'Express':  $transreq[$key] = 'API=ExpressMail&XML=' . urlencode( '<ExpressMailRequest ' . $transitreq . '</ExpressMailRequest>');
                                break;
              case 'Priority': $transreq[$key] = 'API=PriorityMail&XML=' .

To This:
              case 'EXPRESS':  $transreq[$key] = 'API=ExpressMail&XML=' . urlencode( '<ExpressMailRequest ' . $transitreq . '</ExpressMailRequest>');
                                break;
              case 'PRIORITY': $transreq[$key] = 'API=PriorityMail&XML=' .

===Line 324

 
From This:
                case 'Express':     $time = ereg('<MonFriCommitment>(.*)</MonFriCommitment>', $transresp[$service], $tregs);

To This:
                case 'EXPRESS':     $time = ereg('<MonFriCommitment>(.*)</MonFriCommitment>', $transresp[$service], $tregs);

===Line 332:

From This:
                case 'Priority':    $time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);
To This:
                case 'PRIORITY':    $time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);

===Line 352:

From This:
                case 'First Class': $time = '2 - 5 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
To This:
                case 'FIRST CLASS': $time = '2 - 5 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;

Database changes:

 

I used phpmyadmin to manually update the configuratin.

  • Selected the configuration table in the database
  • Found the entry with the following attributes:
    configuration_key = MODULE_SHIPPING_USPS_TYPES
  • For the field 'set_function I change the following values:

  • Express 'changed to' EXPRESS
  • Priority 'changed to' PRIORITY
  • First Class 'changed to' FIRST CLASS

Link to comment
Share on other sites

Did you go back into the module configuration screen in Admin and check to make sure you have selected shipping options (Modules > Shipping > United States Postal Service)?

 

Heather

www.girlcharlee.com

 

I realized that I ran the query twice, but that shouldn't matter, should it? The file says it just changes the shipping from lower to upper case. I ran it once, it didn't seem to do anything, so I ran it again, and after that it totally stopped working and I get this:

 

An error occured with the USPS shipping calculations.

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

 

Can someone please help me?

Link to comment
Share on other sites

My Parcel Post quotes now come more expensive than my Priority !!

 

pix,

 

you can change that by looking for "machinable" in the usps.php code and changing it to "true". at least, that worked for us. backup, backup, backup. test, test, test

Soft, elegant, yet suprisingly affordable

Link to comment
Share on other sites

pix,

 

you can change that by looking for "machinable" in the usps.php code and changing it to "true". at least, that worked for us. backup, backup, backup. test, test, test

 

justpillows, thanks a zillion!

if you are a girl, you deserve a kiss on your mouth!

if you are a man, uhhhh.... a big hug :-)

Link to comment
Share on other sites

I may be a little late to this conversation, but I was having trouble with USPS as well. It's my understanding that this problem is nation wide as one of their programmers decided to change the globals to caps instead of lower case. The fix that worked for me was to go to usps.php and change all the express, parcel, first class and so on to all caps. Once done, I checked the operation and it worked fine. I also discovered a small problem with the Global Express in that it would default to the most expensive. That was also coded to with different Globals and if anyone needs a fix let me know and I'll post it.

I'm not in the middle of nowhere, but I can see it from here!

Link to comment
Share on other sites

Figured out what I was doing wrongly. I hadn't uninstalled the module first. ZI had simply set the 'Do you want to offer USPS shipping?' to False so the database was never modded. Uninstalling the module worked. Just in case anyone else is as bad at reading instructions as I am...

 

Hi,

 

I'm really struggling to get this contib working. I think that my database is not right. In the contribution sql query needed by bobbitodrake 3 Oct 2007 there is mention made of getting the configuration ID:

I don't have MODULE_SHIPPING_USPS_TYPES_INTL.

mysql> SELECT configuration_key, configuration_id from configuration WHERE configuration_key LIKE '%USPS%';
+---------------------------------+------------------+
| configuration_key			   | configuration_id |
+---------------------------------+------------------+
| MODULE_SHIPPING_USPS_SORT_ORDER |			  177 |
| MODULE_SHIPPING_USPS_ZONE	   |			  176 |
| MODULE_SHIPPING_USPS_TAX_CLASS  |			  175 |
| MODULE_SHIPPING_USPS_HANDLING   |			  174 |
| MODULE_SHIPPING_USPS_PASSWORD   |			  172 |
| MODULE_SHIPPING_USPS_SERVER	 |			  173 |
| MODULE_SHIPPING_USPS_USERID	 |			  171 |
| MODULE_SHIPPING_USPS_STATUS	 |			  170 |
+---------------------------------+------------------+
8 rows in set (0.00 sec)

 

My Admin -> Modules ->Shipping page shows3 new blank text boxes after the Sort Order entry and no description of what they are for.

 

Any suggestions?

Link to comment
Share on other sites

For those still getting the dreaded parse error after all the sql updates and all, I discovered the issue, at least on my mysql 4 server. it was not inserting the sql completely, probably due to mysql 4 limitations. So, brace yourself - you'll have to go into phpMyAdmin and select the "configuration" table and find the "MODULE_SHIPPING_USPS_TYPES_INTL" configuration key and edit it manually. Now, edit the set_function so that it reads exactly as follows:

 

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'),

 

hope this helps.

 

Scott

Link to comment
Share on other sites

For those still getting the dreaded parse error after all the sql updates and all, I discovered the issue, at least on my mysql 4 server. it was not inserting the sql completely, probably due to mysql 4 limitations. So, brace yourself - you'll have to go into phpMyAdmin and select the "configuration" table and find the "MODULE_SHIPPING_USPS_TYPES_INTL" configuration key and edit it manually. Now, edit the set_function so that it reads exactly as follows:

 

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'),

 

hope this helps.

 

Scott

 

Scott,

If you are using a version of mySQL below 5.0.3, simply change the data type for the set_function field in the configuration table from VARCHAR(255) to TEXT. It works fine.

 

--Glen

Link to comment
Share on other sites

Scott,

If you are using a version of mySQL below 5.0.3, simply change the data type for the set_function field in the configuration table from VARCHAR(255) to TEXT. It works fine.

 

--Glen

 

Thanks Glen.

 

Scott

Link to comment
Share on other sites

Using USPS Methods, the contribution gave an error for "France, Metropolitan". It failed to give a quote and came up with error: -2147219080 - Missing value for Country.

 

I see several problems with this the last few years in searching, but no solutions... <_<

 

The Country Codes are there: FX and FXX. Are these valid for USPS?

 

Anyone at all have any ideas or a solution?

 

Thanks for your help.

 

RDB

Link to comment
Share on other sites

OK everybody, I don't know if anyone else is still getting this issue, but my Parcel Post quotes are still higher than both 1st Class quotes and Priority Mail quotes. I tried the "machinable" set to true fix and it didn't fix it for me for some reason. Any thoughts? Since our store only offers USPS shipping, I'd love to get this quoted properly, might frustrate potential customers too...

 

thanks!

 

Scott

Link to comment
Share on other sites

I did the mods per instructions, copying the two usps.php files to their locations, the admin/modules file to it's location and made manual change to the general.php file

When I go to the admin panel and click on install the usps function and then hit edit, I get the following error:

 

Parse error: parse error, unexpected T_GLOBAL, expecting ')' in /hsphere/local/home/shoppein/shoppeintheforest.com/admin/modules.php(216) : eval()'d code on line 1.

 

I don't know how to fix this. I can'g find the missing ')' and don't know where to look.

 

Please help.

Link to comment
Share on other sites

OK everybody, I don't know if anyone else is still getting this issue, but my Parcel Post quotes are still higher than both 1st Class quotes and Priority Mail quotes. I tried the "machinable" set to true fix and it didn't fix it for me for some reason. Any thoughts? Since our store only offers USPS shipping, I'd love to get this quoted properly, might frustrate potential customers too...

 

thanks!

 

Scott

Any solutions to this from anyone? I too find parcel coming out higher.

 

Scott: Thanks for your fix on the parse error. After changing the type to text and rerunning the sql code it all works. Does anyone know what we are supposed to do with the instructions.php file that is included in usps methods latest version? The installation instructions do not address it. The installation instructions also do not address running the sql file or when to do it.

 

Scott thanks again.

 

Jim

Link to comment
Share on other sites

I don't know if this helps with the Parcel post quotes being higher but I found two errors in the latest uploads of this contribution. Line 95 reads

if($shipping_pounds > 35 || $shipping_ounces < 6){

and it should read

if($shipping_pounds > 35 || ($shipping_pounds == 0 && $shipping_ounces < 6)){

Line 280 reads

default:		   $usps_server = 'testing.shippingapis.com';
					   $api_dll = 'ShippingAPITest.dll';

 

and it should read

default:		   $usps_server = 'stg-production.shippingapis.com';
					   $api_dll = 'shippingapi.dll';

Ignore me if I'm wrong, but I think that the top line should help as it is part of the "ismachinable" test

Thanks for the contribution and the updates to keep the USPS in line.

Christian

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

Link to comment
Share on other sites

Hello,

 

In the past I have always used v2.76 and go through the new rate updates. But on my new server, I thought I would try v2.92a. But, I get the message,

 

An error occured with the USPS shipping calculations.

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

 

Please if someone can tell me if the steps I followed are correct,

 

1. Uploaded the new catalog usps.php

2. modified other files as instructed.

3. ALTER TABLE `configuration` CHANGE `set_function` `set_function` TEXT

4. 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_id` =196 LIMIT 1 ;

 

5. Then ran update.sql supplied in 2.92a contribution.

 

Any help would be great.

 

Thanks JR

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...