Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] - USPS Methods


Recommended Posts

Try the following code in your application_top.php file and see how that works.

 

// set default store time zone
   ini_set('date.timezone', 'America/YOURCITY');

 

 

That seemed to do the trick Jetta!

Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Link to comment
Share on other sites

Thank you fulluvscents! I will give it a shot.

 

Also, do you know now I can create a space between USPS and the weight. Here is what it is showing on my invoice right now, as well as in the admin.

 

Shipping Method: USPS4 lbs, 8.34 oz (Priority Mail®

---Approx. delivery time 3 Days)

 

Would like to have a space between USPS and 4.

 

Thanks

 

Evan

 

Mine only shows the shipping method within the order total area and it shows this:

 

United States Postal Service

0 lbs, 7.2 oz (Parcel Post®): $6.84

Total: $10.23

 

If I had the transit time or insurance displaying, then it would add those below.

 

Mine doesn't say "Shipping method:" and it doesn't say "USPS" anywhere. In fact, I don't have USPS in all caps in any of my files, nor do I have the words "Shipping method:"

 

Is this displaying right below "payment method" or is it displaying in the order total section?

 

It seems redundant to show it above or below "Payment method:", and then also show the shipping method and cost in the order total. That must have been something added in with your shipping estimator module. You could probably remove the display line all together and be just fine (if this is displaying somewhere else in addition to your order total).

 

Or, in lieu of removing the display line, you'll have to find the language that it's pulling from where it defines the title as USPS and add   or <br> after USPS.

 

I'd start with admin/includes/languages/english/ and see if you can find the file in that folder, since this seems to appear only in your admin files.

 

Jetta

Link to comment
Share on other sites

A few notes of interest..

 

I just completed upgrading a new clients site to 5.0.2 USPS Methods.. in application top I had to use the

ini_set

the

date_default_timezone_set

caused an error

 

 

If you are confused as to what time zone to pick from that link in the read me, try this link:

(I had a better one and grrr cant find it now)

http://www.worldtimezone.com/

 

Evan, Jetta is right check your langague file, mine shows up as Jetta's does, not as you are saying it does.. as did the site I just upgraded..

Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Link to comment
Share on other sites

Looked around a little on the boards and couldn't find an answer. Maybe someone can point me in the right direction. I would like to add a note next to an international shipping option. Example: Priority Mail International Flat Rate Small Box (No insurance. No tracking.). Is there an easy way to do this?

 

Thanks in advance.

Link to comment
Share on other sites

Think I found the fix for the spacing issue - at least in regards to the order email that is sent out.

 

In includes/languages/english/modules/shipping/usps.php, change:

 

define('MODULE_SHIPPING_USPS_TEXT_TITLE', 'United States Postal Service<br>');

 

to:

 

define('MODULE_SHIPPING_USPS_TEXT_TITLE', 'United States Postal Service <br>');

 

 

Regarding the addition of (no insurance)(no tracking), that isn't really a simple one, although it certainly could be done. I personally include all of that info in the shipping / returns section of my site. I also have a notice (regarding hazardous materials) in checkout_shipping.php page in simple html - not included in the shipping module at all. If you don't ship domestically using USPS then you could simply change the language file and add the language after United States Postal Service with appropriate spaces and breaks.

Link to comment
Share on other sites

5.2.1 seems to be a good working version of this contribution. Thanks to everyone who contributed to the effort!

 

After installing and doing a little testing, I seem to be getting good rates back. However, after uncommenting the e-mail related lines in usps.php, one of the numerous e-mails that arrived states the following:

 

<HEAD><TITLE>HTTP Error 400</TITLE></HEAD><BODY><H1>BAD REQUEST</H1><P>Your client sent a request that this server didn't understand.<br>Request:

</body></html>

 

Is this something to be worried about?

Edited by robweidman
Link to comment
Share on other sites

5.2.1 seems to be a good working version of this contribution. Thanks to everyone who contributed to the effort!

 

After installing and doing a little testing, I seem to be getting good rates back. However, after uncommenting the e-mail related lines in usps.php, one of the numerous e-mails that arrived states the following:

 

<HEAD><TITLE>HTTP Error 400</TITLE></HEAD><BODY><H1>BAD REQUEST</H1><P>Your client sent a request that this server didn't understand.<br>Request:

</body></html>

 

Is this something to be worried about?

 

Dumb Q, are you sure your user name is correct?? I get those ocassionally, but I have 3 carts running USPS Methods with my user name and I cant figure out why it happens or which cart it is, I checked all the files and all those lines are commented out and none have my address listed and I am almost positive I applied for the password so long ago that they dont have the gmail address they came to.. so I have no answer for that one..

Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Link to comment
Share on other sites

Those are normal. Those errors specifically are from the transit time responses. The module is set up to go through every method and send a request. For those methods that are not in your allowed list or not within the weight threshold, it sends a request of NONE instead of the mail class. So, USPS sends a response of "BAD REQUEST". This never impacts the function on your site, since the module is scripted to disregard error responses and process good responses. If you get zero good responses, then the USPS error language shows up in your shopping cart.

 

In your quote responses, you'll also see errors like this:

 

<RateV4Response><Package ID="0"><Error><Number>-2147219094</Number><Source>;RateEngineV4.ProcessRequest</Source><Description>Service must be Express, Express SH, Express Commercial, Express SH Commercial, First Class, Priority, Priority Commercial, Parcel, Library, BPM, Media, ALL or ONLINE; you passed NONE</Description><HelpFile></HelpFile><HelpContext>1000440</HelpContext></Error></Package>

 

Those happen for the same reason. "You passed NONE" means that the shipping method wasn't allowed or wasn't within the set weight threshold, so a request of mail class "NONE" was sent by the script, and therefore USPS could not process a response.

 

This is how the script weeds out the methods shown to your customers per your settings.

Link to comment
Share on other sites

I keep getting:

 

1074 - Too big column length for column 'set_function' (max = 255). Use BLOB instead

 

ALTER TABLE `configuration` CHANGE `set_function` `set_function` VARCHAR( 1020 )

 

[TEP STOP]

 

 

 

I did the SQL updgrade as:

 

ALTER TABLE `configuration` CHANGE `configuration_value` `configuration_value` TEXT NOT NULL ,

CHANGE `set_function` `set_function` TEXT NULL DEFAULT NULL;

 

Any thoughts?

Link to comment
Share on other sites

I keep getting:

 

1074 - Too big column length for column 'set_function' (max = 255). Use BLOB instead

 

ALTER TABLE `configuration` CHANGE `set_function` `set_function` VARCHAR( 1020 )

 

[TEP STOP]

 

 

 

I did the SQL updgrade as:

 

ALTER TABLE `configuration` CHANGE `configuration_value` `configuration_value` TEXT NOT NULL ,

CHANGE `set_function` `set_function` TEXT NULL DEFAULT NULL;

 

Any thoughts?

 

Comment out line 405

 

		tep_db_query("ALTER TABLE `configuration` CHANGE `set_function` `set_function` VARCHAR( 1020 )");

 

Uninstall and reinstall and see if that works.

Link to comment
Share on other sites

Comment out line 405

 

		tep_db_query("ALTER TABLE `configuration` CHANGE `set_function` `set_function` VARCHAR( 1020 )");

 

Uninstall and reinstall and see if that works.

 

 

Hooray! That seems to have worked. Thanks!

Link to comment
Share on other sites

Thank you for your help again. It was in my order.php file when it is checking for the shipping method. It is below the payment method. With your help I got it figured out. I did add the <br> for the invoice as I think that will look alot better.

 

 

 

 

 

 

Mine only shows the shipping method within the order total area and it shows this:

 

United States Postal Service

0 lbs, 7.2 oz (Parcel Post®): $6.84

Total: $10.23

 

If I had the transit time or insurance displaying, then it would add those below.

 

Mine doesn't say "Shipping method:" and it doesn't say "USPS" anywhere. In fact, I don't have USPS in all caps in any of my files, nor do I have the words "Shipping method:"

 

Is this displaying right below "payment method" or is it displaying in the order total section?

 

It seems redundant to show it above or below "Payment method:", and then also show the shipping method and cost in the order total. That must have been something added in with your shipping estimator module. You could probably remove the display line all together and be just fine (if this is displaying somewhere else in addition to your order total).

 

Or, in lieu of removing the display line, you'll have to find the language that it's pulling from where it defines the title as USPS and add   or <br> after USPS.

 

I'd start with admin/includes/languages/english/ and see if you can find the file in that folder, since this seems to appear only in your admin files.

 

Jetta

Link to comment
Share on other sites

Regarding the addition of (no insurance)(no tracking), that isn't really a simple one, although it certainly could be done. I personally include all of that info in the shipping / returns section of my site. I also have a notice (regarding hazardous materials) in checkout_shipping.php page in simple html - not included in the shipping module at all. If you don't ship domestically using USPS then you could simply change the language file and add the language after United States Postal Service with appropriate spaces and breaks.

 

Thanks a lot for the answer. I pretty much came to the same conclusion. But I didn't know if someone (you in particular) had covered this ground before. But now I feel secure that my initial assumption was correct. I know you're tired of hearing this :P , but thanks for all the work you've done to straighten this mod out! It works great!

Link to comment
Share on other sites

I have a question about the following option:

 

Int'l Package Sizes - Standard package dimensions required by USPS for international rates

 

Width

Length

Height

Girth

 

How does his affect international quotes? My clients don't have any one size of box that they ship, so what kind of guidance can I give them as to how to fill these options in? If the size is over or under, how will that affect the final quote? Will it be high or low?

Link to comment
Share on other sites

The box size won't affect the quote for any particular method. It will only affect which shipping methods are returned in the USPS response. For example, Global express guaranteed states the following:

 

Size, Weight and Content Restrictions

Minimum Size: An envelope/package must be large enough to affix the Global Express Guaranteed Mailing Label to the face of the item (approx. 5.5" in height and 9.5" in length).

 

Maximum Size: Total length and girth not to exceed 108 inches. Individual dimensions not to exceed:

 

Length = 46 inches

Width = 35 inches

Height = 46 inches

 

So if the package isn't large enough for the label, then that method won't be shown.

 

If you use 6X10X1, you'll get GXG, first class package, priority, express, and priority flat rate boxes, but in my case, I'm not getting flat rate envelopes regardless of what dimensions I use.

 

I think this is one point where USPS overstepped their bounds - KNOWING that most businesses who use their API services ship in a variety of package sizes. But, this is how they set it up. You send one set of parameters and they send back the methods that fit within those parameters.

 

The USPS internet customer help desk might be able to give a standard dimension that will work with all mailing types. Could be worth a try but I don't like using telephone, so I won't call. 1-800-344-7779

Edited by fulluvscents
Link to comment
Share on other sites

I only ship domestic, Priority & Express box, internstional, first class, Priority & Express box, so I put in the size fields:

8

6

2

28

 

and I get the rates I need..

Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Link to comment
Share on other sites

Thanks a lot for the answer. I pretty much came to the same conclusion. But I didn't know if someone (you in particular) had covered this ground before. But now I feel secure that my initial assumption was correct. I know you're tired of hearing this :P , but thanks for all the work you've done to straighten this mod out! It works great!

 

Okay, so I opened the module and it dawned on me that there is a simple modification for this.

 

You need to check "display insurance" from your admin panel. If you have insurance set to true for domestic, then your domestic will display as normal. If it is set to false, then domestic insurance shouldn't show anything. To modify the display for international do the following:

 

In the usps.php file, find the following around line 1116:

 

			if (($dispinsurance) && ((MODULE_SHIPPING_USPS_INTL_INSURANCE_OPTION == 'True' && $iinsurance > 0) || (MODULE_SHIPPING_USPS_INSURE == 'True' && $iuinsurance > 0)))
		{$dispinsure[$service] = '<br>' . MODULE_SHIPPING_USPS_TEXT_INSURED . '$' . tep_round_up($insurable, 2);}

 

change to:

 

//			if (($dispinsurance) && ((MODULE_SHIPPING_USPS_INTL_INSURANCE_OPTION == 'True' && $iinsurance > 0) || (MODULE_SHIPPING_USPS_INSURE == 'True' && $iuinsurance > 0)))
//			{$dispinsure[$service] = '<br>' . MODULE_SHIPPING_USPS_TEXT_INSURED . '$' . tep_round_up($insurable, 2);}
		if (($dispinsurance)
		{$dispinsure[$service] = '<br>---No Insurance.  No tracking';}

 

This will display the text beneath every international method.

Edited by fulluvscents
Link to comment
Share on other sites

close fix Jetta, but all others besides First Class do other some level of tracking.

 

To my understanding:

Priority : tracked to the US border, some countries will report back to USPS when delivered etc, some wont.

Express : door to door tracking to any country

 

I would also like to make notation that First Class International holds no tracking and no insurance. I do have that info on my shipping page, but it should be stated on the shipping checkout page also I think for clairty purposes.

 

This is what my Shipping page shows:

 

  • USPS Priority International shipments are trackable ONLY until it reaches your country. If the package is lost or damaged past point of entry, we can not take any responsibility.
  • USPS Express Mail International includes tracking door to door to most countries.
  • First-Class Mail International - First Class Mail does NOT have tracking features or insurance. We take no responsibility for lost or damaged shipments.

Edited by wkdwich

Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Link to comment
Share on other sites

If they want this displayed only for certain methods, then no, it won't work. If for all international methods, then it will work just fine. Depends solely on whether or not it is what the poster was looking for.

 

But, I can't pass up a challenge. So, here you go.

 

To set the display for particular methods, find on line 1118:

		if (($dispinsurance) && ((MODULE_SHIPPING_USPS_INTL_INSURANCE_OPTION == 'True' && $iinsurance > 0) || (MODULE_SHIPPING_USPS_INSURE == 'True' && $iuinsurance > 0)))
		{$dispinsure[$service] = '<br>' . MODULE_SHIPPING_USPS_TEXT_INSURED . '$' . tep_round_up($insurable, 2);}
		else {$dispinsure[$service] = '';}			

 

AFTER THIS, add the following:

 

			switch ($service)
		{
		case 'First-Class Mail reg International Letter**':  $dispinsure[$service] = '<br>---No Insurance.  No tracking';
		break;
		case 'First-Class Mail reg International Package**':  $dispinsure[$service] = '<br>---No Insurance.  No tracking';
		break;
		case 'First-Class Mail reg International Large Envelope**':  $dispinsure[$service] = '<br>---No Insurance.  No tracking';
		break;
		}

 

This is an example only.

 

You'll need to add the case and break line for EACH international type that you want this applied to. The types can be found in the intl_types array on line 75.

 

You do NOT need to set "display insurance" to true from the admin panel. This will be hardcoded.

 

However, if you DO set "display insurance" and you do force insurance, then this will overwrite insurance displays for the specified methods only. In other words, if you only specify 1st class in the case/break rule then this is the only method that will display the text. The other methods will display their default text (insured for $X.XX)

 

Suppose it was easier than I thought it would be. This is hard coded and user specific. It is not controlled from admin, so if any further contributions are installed, you'll need to re-add this code manually.

Link to comment
Share on other sites

thanks Jetta,

 

the admin/modules.php change is what I was missing.

 

*****************************************
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'])) {

 

reads in the 3.2.1 admin/modules.php as

 

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

 

posted this mainly to help others if they see the same issue

 

You didn't take this line out of 2.3.1 did you?

reset($HTTP_POST_VARS['configuration']);

 

I can't get the module to work...

 

I get the same error message you had:

An error occured with the USPS shipping calculations.

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

 

I followed the instructions for "Update to 2.9.X or earlier."

Web Developer, Firebug, and Notepad++ are powerful free tools for web design.

Link to comment
Share on other sites

You didn't take this line out of 2.3.1 did you?

reset($HTTP_POST_VARS['configuration']);

 

I can't get the module to work...

 

I get the same error message you had:

 

I followed the instructions for "Update to 2.9.X or earlier."

 

you aren't replacing. you're adding to what you already have. So, nothing should have been taken out.

 

The module has worked fine on osc2.3.1 for others so I don't see any reason you'd want to remove that line. If someone with 2.3.1 wants to chime in to confirm that, it would help.

 

Did USPS email you and tell you that they switched you to the production server yet? If you didn't get the email, then you are not switched yet.

 

If so, confirm that so I don't chase my tail (nor you yours). If not, then send them another email specifying that you are using an oscommerce module. They won't switch you unless they can confirm that testing has been done with your user id or if they know you are using tested third party software (OSC).

Link to comment
Share on other sites

\catalog\admin\modules.php

shou;d now look like:

 

  if (tep_not_null($action)) {
   switch ($action) {
     case 'save':
       while (list($key, $value) = each($HTTP_POST_VARS['configuration'])) {
// BOF: LINES ADDED
         if( is_array( $value ) ){
         $value = implode( ", ", $value);
	  $value = ereg_replace (", --none--", "", $value);
	    }
// EOF: LINES ADDED

 

If thats not what you have that is ost likely your problem.

Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Link to comment
Share on other sites

you aren't replacing. you're adding to what you already have. So, nothing should have been taken out.

 

The module has worked fine on osc2.3.1 for others so I don't see any reason you'd want to remove that line. If someone with 2.3.1 wants to chime in to confirm that, it would help.

 

Did USPS email you and tell you that they switched you to the production server yet? If you didn't get the email, then you are not switched yet.

 

If so, confirm that so I don't chase my tail (nor you yours). If not, then send them another email specifying that you are using an oscommerce module. They won't switch you unless they can confirm that testing has been done with your user id or if they know you are using tested third party software (OSC).

That's what I thought...I only added as the directions stated, no changes to the 2.3.1 code. I only asked because of the error I am getting.

 

I am on the production server now.

 

I double checked all the steps, but I suppose I can check again.

Web Developer, Firebug, and Notepad++ are powerful free tools for web design.

Link to comment
Share on other sites

\catalog\admin\modules.php

shou;d now look like:

 

  if (tep_not_null($action)) {
   switch ($action) {
     case 'save':
       while (list($key, $value) = each($HTTP_POST_VARS['configuration'])) {
// BOF: LINES ADDED
         if( is_array( $value ) ){
         $value = implode( ", ", $value);
	  $value = ereg_replace (", --none--", "", $value);
	    }
// EOF: LINES ADDED

If thats not what you have that is most likely your problem.

 

This is what I have:

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


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

 

I tried with and without:

reset($HTTP_POST_VARS['configuration']);

but it made no difference in the error. The above line is standard with 2.3.1.

 

I have to confess, I did accidentally/stupidly, start by doing the "INSTRUCTIONS: Update from V 4.0.x to 4.2.x ." So I did steps 1-7, tried to use it, then realized what I did. Then I backtracked, and made all the changes necessary to make sure the "INSTRUCTIONS: Update to 2.9.X or earlier" were completed-- twice. Did the sql step mess me up?

Web Developer, Firebug, and Notepad++ are powerful free tools for web design.

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