Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] - USPS Methods


Recommended Posts

Here we go again. USPS is making changes to the API. How will this affect us? Here is a snippet of the email they sent to me:

-----------------------------------------------------------------------------------------------------------------------------------------------------

Dear customer,

 

On May 12, 2008 several APIs will be altered in response to the USPS Price Change (http://www.usps.com/prices/welcome.htm). While the APIs listed below will remain structurally and syntactically backward compatible, data changes are possibly substantial enough to affect some integrators. Please contact [email protected] (1-800-344-7779) with any specific schema or enumeration questions.

 

 

Effective 5/12/2008, the APIs will consist of the following changes:

• Integration of domestic and international price changes across all Web Tools APIs that use rates

• Merchandise Return API Insurance/Fee calculation updated for 2008 Price Change

• PriorityMail/StandardB API Service Standard data updated

• First Class Mail International API supports three shapes, machinability

• Deprecated GlobalLabelAirmail, GlobalLabelExpress APIs are no longer available

• IntlRate API supports three First Class Mail International product shapes now (new enumerations), addition of optional machinable attribute

• Signature Confirmation API reflects changed SC fee

 

Most impacted will be the integrators using RateV2 and IntlRate as shown below.

Link to comment
Share on other sites

I am surprised nobody is chattering about this yet (except us). I got the email too and was a bit impressed that USPS was being slightly proactive. I suppose we won't hear anything until they implement this on Monday morning. Then people will be freaking out if it breaks stuff... I am watching this thread! Cross your fingers - maybe everything will be fine.

Link to comment
Share on other sites

Proactive? HA!

One - I havn't gotten that email yet

 

Two- I went to the post office on Friday to drop off a letter and wanted to buy some new stamps for Monday. They didn't have any yet... lol. I had to get a ton of $.02 stamps for my business.

 

I suggest we make a module that allows for the input of all the data manually as a backup, because I'm sure everyone doesn't use every product.

 

P.S. As long as they don't change the tag names, the product names, or add package input requirements in the API (ex added <container>LETTER</container> in API v3.0), everything should be a smooth transition.

Link to comment
Share on other sites

I went to the post office on Friday to drop off a letter and wanted to buy some new stamps for Monday. They didn't have any yet...

 

Were they out of the Forever stamps? I would think that purchasing a ton of those would save you a little money down the road.

 

I also received the email, on Friday, although I have not yet had the chance to browse through the changes. I am excited about the new online discounts for Priority and Express Mail, however. I use Stamps.com for my domestic shipping, and the Priority discounts may allow me to offer shipping discounts more frequently.

Link to comment
Share on other sites

I needed International stamps at $.94/oz. Half the time I need two. Not enough space for 10 stamps.

 

 

BTW... They changed the API tags for international rates. I've fixed it and am uploading v4.1 There are now options for Firstclass package, letter, or large envelope. Also options for priority flatrate box and large flatrate box inside usps.php.

Link to comment
Share on other sites

I am now getting Flat Rate Envelope appearing in my checkout. This did not show up previously and I have updated to 4.1 (followed all steps exactly).

 

The product weight is set to 1 lb, and that seems heavy for an envelope. I can deselect the flat-rate items for international, but not the domestic.

 

Any ideas how to have it only return package rates and no envelope rates or flat-rates?

Link to comment
Share on other sites

I needed International stamps at $.94/oz. Half the time I need two. Not enough space for 10 stamps.

BTW... They changed the API tags for international rates. I've fixed it and am uploading v4.1 There are now options for Firstclass package, letter, or large envelope. Also options for priority flatrate box and large flatrate box inside usps.php.

 

Hmmm is this why I suddenly only have the choice of Express International and Priority International. I no longer see First Class International showing up in the international shipping. Any quick remedy to get the first class international rates back up?

Link to comment
Share on other sites

I've fixed it and am uploading v4.1 There are now options for Firstclass package, letter, or large envelope. Also options for priority flatrate box and large flatrate box inside usps.php.

 

"priority flatrate box and large flatrate box inside usps.php"

 

I don't see these options after updating??????

Link to comment
Share on other sites

I'm having the same issue. If I have a 1lb+ package that it is only coming back with Priority Mail Flat-Rate Envelope. The priority pricing is not adjusting at all. Stays at the one pound rate no matter what. I take it this is only returning the flat rate instead of package. Need to fix this and I should be fine.

Link to comment
Share on other sites

I figured out what to do with getting rid of the priority flat rate box. I just changed the string to:

 

//PRIORITY MAIL OPTIONS
	if ($key == 'PRIORITY'){
		$this->container = '';
	}

 

And now it comes up as just Priority and it is calculating according to the weight instead of flat box. Basically just make the container = null :)

Link to comment
Share on other sites

I just installed v4.1 Beta from v2.9.2 and on the checkout_shipping page the options I have set (currently First Class, Priority, Parcel and Express Mail) seem to show up correctly with their correct rates, but First Class is the only option to show estimated shipping time. However, the biggest problem I have is that on the confirmation page, the shipping rate automatically defaults to and charges Express Mail no matter what is chosen (upon going back to checkout_shipping, it will show the option that was originally selected). This is only happening for domestic orders. The international options seem to work just fine and will keep the selected option through the checkout process.

 

Is anyone else having this same problem of defaulting to Express Mail and only First Class showing the estimated shipping, or have ideas on how I might fix this?

 

I am running osCommerce v2.2 RC1. I had a similar problem back in November when all the options changed to upper case, but my configurations were updated to reflect that. I've been going over the code all morning and I just can't seem to pinpoint where the trouble is.

 

Thanks in advance for any help you may be able to give me to get my site working properly again :)

 

P.S. Thanks also for providing an updated USPS module so quickly :) It's greatly appreciated!

Link to comment
Share on other sites

Hmmm is this why I suddenly only have the choice of Express International and Priority International. I no longer see First Class International showing up in the international shipping. Any quick remedy to get the first class international rates back up?

 

I got First Class international to show up properly by changing this:

 

//FIRST CLASS MAIL INTERNATIONAL OPTION:
$this->FirstClassIntType = 'Letters';  //OPTIONS: 'Letters', 'Package', 'Large Envelope'

 

to this:

 

//FIRST CLASS MAIL INTERNATIONAL OPTION:
$this->FirstClassIntType = 'Package';  //OPTIONS: 'Letters', 'Package', 'Large Envelope'

Link to comment
Share on other sites

I just installed v4.1 Beta from v2.9.2 and on the checkout_shipping page the options I have set (currently First Class, Priority, Parcel and Express Mail) seem to show up correctly with their correct rates, but First Class is the only option to show estimated shipping time. However, the biggest problem I have is that on the confirmation page, the shipping rate automatically defaults to and charges Express Mail no matter what is chosen (upon going back to checkout_shipping, it will show the option that was originally selected). This is only happening for domestic orders. The international options seem to work just fine and will keep the selected option through the checkout process.

 

Is anyone else having this same problem of defaulting to Express Mail and only First Class showing the estimated shipping, or have ideas on how I might fix this?

 

I am running osCommerce v2.2 RC1. I had a similar problem back in November when all the options changed to upper case, but my configurations were updated to reflect that. I've been going over the code all morning and I just can't seem to pinpoint where the trouble is.

 

Thanks in advance for any help you may be able to give me to get my site working properly again :)

 

P.S. Thanks also for providing an updated USPS module so quickly :) It's greatly appreciated!

 

 

I have the same exact problem. I have fixed the Priority and Express Mail flat rate issue and also the First Class International issue. But this one is a little beyond me. I had the same problem as well before and cant remember what fixed it. Express defaults on the confirmation page. If I remember correctly, unlikely, it was the names of the values that need to be changed in the database and hence in the usps.php file under the install section.

 

Hopefully we can get this sorted out soon as it is hurting my domestic ordering right now.

 

Chris

Link to comment
Share on other sites

i don't think it's exclusively defaulting to Express for domestic... it seems to select the "highest" (i.e. fastest) of your selected options... the stores i'm modifying use Priority as the highest method and it's defaulting to that.

 

anyone figure this out yet?

Link to comment
Share on other sites

First Class is the only option to show estimated shipping time.

 

I figured out how to get the other options to show the estimated shipping times by doing the following:

Around line 383:

if ($transit) {
             switch ($service) {
               case 'EXPRESS':     $time = ereg('<MonFriCommitment>(.*)</MonFriCommitment>', $transresp[$service], $tregs);
                                   $time = $tregs[1];
                                   if ($time == '' || $time == 'No Data') {
                                     $time = 'Estimated 1 - 2 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                   } else {
                                     $time = 'Tomorrow by ' . $time;
                                   }
                                   break;
               case 'PRIORITY':    $time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);
                                   $time = $tregs[1];
                                   if ($time == '' || $time == 'No Data') {
                                     $time = 'Estimated 1 - 3 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                   } elseif ($time == '1') {
                                     $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAY;
                                   } else {
                                     $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                   }
                                   break;

 

I changed each case to their non-all-caps equivalent: 'Express Mail', 'Priority Mail', 'Parcel Post':

 

if ($transit) {
             switch ($service) {
               case 'Express Mail':     $time = ereg('<MonFriCommitment>(.*)</MonFriCommitment>', $transresp[$service], $tregs);
                                   $time = $tregs[1];
                                   if ($time == '' || $time == 'No Data') {
                                     $time = 'Estimated 1 - 2 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                   } else {
                                     $time = 'Tomorrow by ' . $time;
                                   }
                                   break;
               case 'Priority Mail':    $time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);
                                   $time = $tregs[1];
                                   if ($time == '' || $time == 'No Data') {
                                     $time = 'Estimated 1 - 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 Post':      $time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);
                                   $time = $tregs[1];
                                   if ($time == '' || $time == 'No Data') {
                                     $time = 'Estimated 2 - 9 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                   } elseif ($time == '1') {
                                     $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAY;
                                   } else {
                                     $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                   }
                                   break;

 

and the estimated shipping times are now all showing up as they should. 'First-Class Mail' is already in non-all-caps, therefore was showing up correctly at the start.

 

I'm still having trouble with the shipping quote defaulting to whatever is "on top" on the confirmation screen, I removed Express Mail and Parcel Post as options, and left First Class and Priority, and now it defaults to First Class everytime.

Link to comment
Share on other sites

I figured out how to get the other options to show the estimated shipping times by doing the following:

Around line 383:

if ($transit) {
             switch ($service) {
               case 'EXPRESS':     $time = ereg('<MonFriCommitment>(.*)</MonFriCommitment>', $transresp[$service], $tregs);
                                   $time = $tregs[1];
                                   if ($time == '' || $time == 'No Data') {
                                     $time = 'Estimated 1 - 2 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                   } else {
                                     $time = 'Tomorrow by ' . $time;
                                   }
                                   break;
               case 'PRIORITY':    $time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);
                                   $time = $tregs[1];
                                   if ($time == '' || $time == 'No Data') {
                                     $time = 'Estimated 1 - 3 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                   } elseif ($time == '1') {
                                     $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAY;
                                   } else {
                                     $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                   }
                                   break;

 

I changed each case to their non-all-caps equivalent: 'Express Mail', 'Priority Mail', 'Parcel Post':

 

if ($transit) {
             switch ($service) {
               case 'Express Mail':     $time = ereg('<MonFriCommitment>(.*)</MonFriCommitment>', $transresp[$service], $tregs);
                                   $time = $tregs[1];
                                   if ($time == '' || $time == 'No Data') {
                                     $time = 'Estimated 1 - 2 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                   } else {
                                     $time = 'Tomorrow by ' . $time;
                                   }
                                   break;
               case 'Priority Mail':    $time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);
                                   $time = $tregs[1];
                                   if ($time == '' || $time == 'No Data') {
                                     $time = 'Estimated 1 - 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 Post':      $time = ereg('<Days>(.*)</Days>', $transresp[$service], $tregs);
                                   $time = $tregs[1];
                                   if ($time == '' || $time == 'No Data') {
                                     $time = 'Estimated 2 - 9 ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                   } elseif ($time == '1') {
                                     $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAY;
                                   } else {
                                     $time .= ' ' . MODULE_SHIPPING_USPS_TEXT_DAYS;
                                   }
                                   break;

 

and the estimated shipping times are now all showing up as they should. 'First-Class Mail' is already in non-all-caps, therefore was showing up correctly at the start.

 

I'm still having trouble with the shipping quote defaulting to whatever is "on top" on the confirmation screen, I removed Express Mail and Parcel Post as options, and left First Class and Priority, and now it defaults to First Class everytime.

 

What would it be for Media? "Media Mail"?

Link to comment
Share on other sites

Ok, I finally figured out what was going on and why it was defaulting to the top option. Seems the USPS API switched back to non-all-caps for domestic.

 

Around Line 47:

      $this->types = array('EXPRESS' => 'Express Mail',
					   'FIRST CLASS' => 'First-Class Mail',
					   'PRIORITY' => 'Priority Mail',
					   'PARCEL' => 'Parcel Post',
					   'BPM' => 'Bound Printed Matter',
					   'MEDIA' => 'Media Mail');

 

Change to:

      $this->types = array('Express Mail' => 'Express Mail',
					   'First-Class Mail' => 'First-Class Mail',
					   'Priority Mail' => 'Priority Mail',
					   'Parcel Post' => 'Parcel Post',
					   'Bound Printed Matter' => 'Bound Printed Matter',
					   'Media Mail' => 'Media Mail');

 

Around line 171:

 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, BMP, MEDIA,', 'Select the domestic services to be offered:', '6', '0', 'tep_cfg_select_multioption(array(\'EXPRESS\', \'PRIORITY\', \'FIRST CLASS\', \'PARCEL\',\'BPM\',\'MEDIA\'), ', now())");

 

Change to:

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 Mail, Priority Mail, First-Class Mail, Parcel Post, Bound Printed Matter, Bound Printed Matter, Media Mail', 'Select the domestic services to be offered:', '6', '0', 'tep_cfg_select_multioption(array(\'Express Mail\', \'Priority Mail\', \'First-Class Mail\', \'Parcel Post\',\'Bound Printed Matter\',\'Media Mail\'), ', now())");

 

Around line 232:

//FIRST CLASS MAIL OPTIONS
	if ($key == 'FIRST CLASS'){
		$this->FirstClassMailType = '<FirstClassMailType>LETTER</FirstClassMailType>';
	} else {
		$this->FirstClassMailType = '';
	}

//PRIORITY MAIL OPTIONS
	if ($key == 'PRIORITY'){
		//$this->container = 'FLAT RATE ENVELOPE';
                         $this->container = '';
	}

//EXPRESS MAIL OPTIONS
	if ($key == 'EXPRESS'){
		//$this->container = 'FLAT RATE ENVELOPE';
                         $this->container = '';
	}

//PARCEL POST OPTIONS
	if ($key == 'PARCEL POST'){
		$this->container = 'REGULAR';
		$this->machinable = 'false';
	}

 

Change to:

//FIRST CLASS MAIL OPTIONS
	if ($key == 'First-Class Mail'){
		$this->FirstClassMailType = '<FirstClassMailType>LETTER</FirstClassMailType>';
	} else {
		$this->FirstClassMailType = '';
	}

//PRIORITY MAIL OPTIONS
	if ($key == 'Priority Mail'){
		//$this->container = 'FLAT RATE ENVELOPE';
                         $this->container = '';
	}

//EXPRESS MAIL OPTIONS
	if ($key == 'Express Mail'){
		//$this->container = 'FLAT RATE ENVELOPE';
                         $this->container = '';
	}

//PARCEL POST OPTIONS
	if ($key == 'Parcel Post'){
		$this->container = 'REGULAR';
		$this->machinable = 'false';
	}

 

Since I already posted code for getting the estimated shipping text to appear on checkout_shipping page, I did not add it here. See my previous post for the changes.

 

Basically, you want to change any upper case options to: Express Mail, Priority Mail, First-Class Mail, Parcel Post, Bound Printed Matter, Media Mail

 

You will need to run the following SQL in phpMyAdmin:

UPDATE configuration SET set_function='tep_cfg_select_multioption(array(''Express Mail'', ''Priority Mail'', ''First-Class Mail'', ''Parcel Post'', ''Bound Printed Matter'', ''Media Mail''), ' WHERE configuration_key='MODULE_SHIPPING_USPS_TYPES'

 

You will also need to make sure that the configuration_value for MODULE_SHIPPING_USPS_TYPES reflects the new options you use for your store.

Link to comment
Share on other sites

Lots of issues going on with the USPS changes - don't know if this makes a difference for anybody; however, I'm still using 3.0 on my site and getting accurate quotes just fine domestically (haven't tested international). The catch is that it quotes the new "regular" USPS rate rather than the "discounted" Click n Ship Rate.

 

So, if you are in a bind, revert!

 

Scott

Link to comment
Share on other sites

This is what I am experiencing with USPS Methods 4.1 Beta.

Everything appears fine. At checkout I choose First Class International Mail. Then at the confirm order page I am charged for Express Mail. No matter what option I choose at checkout, Express Mail shows up at confirmation.

When testing your store to see if this works be sure to continue the order process all the way to confirmation. Anyone else?

Link to comment
Share on other sites

I've installed 3.0 and everything is working just the way I would like. However, when I edit the usps shipping moduel the following error occurs.

 

Parse error: syntax error, unexpected T_GLOBAL, expecting ')' in /home/texmood/public_html/catalog/admin/modules.php(216) : eval()'d code on line 1

 

All the codeing looks correct. Can't figure out what is causing this. But, I wanted to fix in order to prevent future issues.

 

Can anyone direct me to possable causes?

 

Thanks.

Link to comment
Share on other sites

:blink: Never mind. Always helps to read entire instuctions. Including tips!!

 

I've installed 3.0 and everything is working just the way I would like. However, when I edit the usps shipping moduel the following error occurs.

 

Parse error: syntax error, unexpected T_GLOBAL, expecting ')' in /home/texmood/public_html/catalog/admin/modules.php(216) : eval()'d code on line 1

 

All the codeing looks correct. Can't figure out what is causing this. But, I wanted to fix in order to prevent future issues.

 

Can anyone direct me to possable causes?

 

Thanks.

Link to comment
Share on other sites

I've installed 3.0 and everything is working just the way I would like. However, when I edit the usps shipping moduel the following error occurs.

 

Parse error: syntax error, unexpected T_GLOBAL, expecting ')' in /home/texmood/public_html/catalog/admin/modules.php(216) : eval()'d code on line 1

 

All the codeing looks correct. Can't figure out what is causing this. But, I wanted to fix in order to prevent future issues.

 

Can anyone direct me to possable causes?

 

Thanks.

 

Look at the Troubleshooting section of the install guide.

 

Scott

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...