Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] - USPS Methods


Recommended Posts

Ugh... It's really hard to try and troubleshoot when my OSCommerce installation doesn't have those errors. I am using the same module everyone else is using and it works perfectly (for me). So If you're having problems and need it to work "yesterday", please use the previous version untill I can work out the kinks in this Beta with the "Beta Testers".

 

I appreciate everyone's involvement but please be patient with me as college has just started and I'm taking online courses, school courses, working one job, and trying to run a business all at the same time.

 

I just wanted to say thanks to Greg for all his hard work re-coding this addon...

 

Scott

Link to comment
Share on other sites

I'm having an odd issue with USPS 3.0 I updated the names and such and on occasion it works fine, but lately, a great majority of the time when a customer clicks First Class Mail they get a CGI time out. This has occurred, on rare occasion, with other USPS shipping methods but with First Class Mail it's occurs very often. In fact it screws up more often than it actually works. Has anyone had this problem, or does anyone know a way to track this to fix it?

Link to comment
Share on other sites

  • 3 weeks later...
the forum won't let me edit my post... strange.

 

anyway just a quick note, you need to add '$rates_sorter[] = $postage;'

after both occurrences of '$rates[] = array($service => $postage);'

otherwise you will get no results for either international or domestic rates (depending on which one you didn't add);

 

Thank you Ben for this code!

 

Scott

Link to comment
Share on other sites

I'm having an odd issue with USPS 3.0 I updated the names and such and on occasion it works fine, but lately, a great majority of the time when a customer clicks First Class Mail they get a CGI time out. This has occurred, on rare occasion, with other USPS shipping methods but with First Class Mail it's occurs very often. In fact it screws up more often than it actually works. Has anyone had this problem, or does anyone know a way to track this to fix it?

 

Thanks for writing. I still use 3.0 on my site with the sorting code additions by Ben. I have tried to duplicate your issue, but have not been able to. It works great on my store and I have never had any issues to date that I am aware of... If I had to guess, it would be that it was a temporary usps server issue - also, you should not have had to update any of the names for 3.0, only changed the set_function field to "text" for it to work fine as is...

 

Scott

Link to comment
Share on other sites

  • 2 weeks later...

Today, I upgraded to USPS Methods v4.3 Alpha... I was able to duplicate the USPS 3.0 issue mentioned above, timeouts; however, I get the same issue with v4.3 - it hangs and times out often. I must attribute this to USPS Servers as I can't find any problems with the code itself at this point - this is a bummer for those of us who only use USPS to ship.

 

Also, for those of you who don't want the weight duplicated in the title in v4.3 (it is listed once as "(1 x 1.6lbs)" and then lists it again broken up into pounds and ounces "1lbs 8oz"), this is my fix:

 

Find this:

 

	// usps doesn't accept zero weight
 // Modified by Greg Deeth on May 27th 2008
 //$shipping_weight = $shipping_weight - .15;
 if ($shipping_weight <= 0) {$shipping_weight = 0;}  //This will cause an error if the seller forgets to assign a weight for the product. This keeps buyers from having cheap shipping by accident.
   $shipping_weight = ($shipping_weight < 0.0625 ? 0.0625 : $shipping_weight);
   $shipping_pounds = floor ($shipping_weight);
   $shipping_ounces = tep_round_up((16 * ($shipping_weight - floor($shipping_weight))), 2);
   $this->_setWeight($shipping_pounds, $shipping_ounces, $shipping_weight);
 // Added by Kevin Chen ([email protected]); Fixes the Parcel Post Bug July 1, 2004
 // Refer to http://www.usps.com/webtools/htm/Domestic-Rates.htm documentation
 // Thanks Ryan
 // End Kevin Chen July 1, 2004
   /*
 THE FOLLOWING FUNCTION CAUSES A 500 ERROR WHEN USING PAYPAL EXPRESS
 function round_up($valueIn, $places=0) {
	 if ($places < 0) { $places = 0; }
	 $mult = pow(10, $places);
	 return (ceil($valueIn * $mult) / $mult);
	 }
 */

 

Insert this AFTER:

 

	  if ($shipping_pounds <= 1) {
	 if ($shipping_pounds == 0) {
	   $shipping_pounds = '';
	   $lb_text = '';
	 } else {
	   $lb_text = 'lb ';
	 }
   } else {
	 $lb_text = 'lbs ';
   }

   if ($shipping_ounces <= 1) {
	 if ($shipping_ounces == 0) {
	   $shipping_ounces = '';
	   $oz_text = '';
	 } else {
	   $oz_text = 'oz';
	 }
   } else {
	 $oz_text = 'oz';
   }

 

 

Find this:

 

			  $shiptitle = ' (' . $shipping_num_boxes . ' x ' . tep_round_up($shipping_weight, 2) . 'lbs)' . ' (' . $shipping_pounds . 'lbs, ' . $shipping_ounces . 'oz)';

 

REPLACE with this:

 

		$shiptitle = ' (' . $shipping_num_boxes . ' x ' . $shipping_pounds . $lb_text . $shipping_ounces . $oz_text . ')';

 

Scott

Edited by olsonsp4c
Link to comment
Share on other sites

I just upgraded to 4.2.1 and while its nice it also created a few problems for me.

 

The module installs just fine from the admin/modules.php page, however when I go to hit "edit" I get this error:

 

Fatal error: Call to undefined function: tep_cfg_select_multioption() in /htdocs/catalog/admin/modules.php(212) : eval()'d code on line 1

 

Searching around there appears to be no fix that I can find. I got around it by opening up the MySQL file and editing the individual options by hand, the long way. Very slow.

 

 

Now, the biggest problem of them all is that admin/orders.php does not recognize that there are new orders there. The 3-4 test orders (and 2 live ones) that have gone through since I upgraded are in the SQL database but the admin/orders.php does not view them.

 

Does anyone have any suggestions as to what may be the issue here?

 

Thank you for your time,

--Martin--

Link to comment
Share on other sites

I just upgraded to 4.2.1 and while its nice it also created a few problems for me.

 

The module installs just fine from the admin/modules.php page, however when I go to hit "edit" I get this error:

 

Fatal error: Call to undefined function: tep_cfg_select_multioption() in /htdocs/catalog/admin/modules.php(212) : eval()'d code on line 1

 

Searching around there appears to be no fix that I can find. I got around it by opening up the MySQL file and editing the individual options by hand, the long way. Very slow.

 

 

Now, the biggest problem of them all is that admin/orders.php does not recognize that there are new orders there. The 3-4 test orders (and 2 live ones) that have gone through since I upgraded are in the SQL database but the admin/orders.php does not view them.

 

Does anyone have any suggestions as to what may be the issue here?

 

Thank you for your time,

--Martin--

 

You didn't complete the step where you were supposed to edit catalog/admin/includes/modules.php and add the following function:

 

// 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;
 }

 

Scott

Link to comment
Share on other sites

You didn't complete the step where you were supposed to edit catalog/admin/includes/modules.php and add the following function:

 

Scott

 

Actually I did. I followed the install directions in the file quite carefully. It seems I had some other code in there that was messing it up. I deleted it and now the edit feature works.

The orders.php still isnt working though, so thats another thing for me to troubleshoot now.

 

Thanks for the help!

--Martin--

Link to comment
Share on other sites

Actually I did. I followed the install directions in the file quite carefully. It seems I had some other code in there that was messing it up. I deleted it and now the edit feature works.

The orders.php still isnt working though, so thats another thing for me to troubleshoot now.

 

Thanks for the help!

--Martin--

 

Could you please post your changes, what you edited? it might help others who had the same issue...

Also, do you mean that the order is placed, it shows up in the database, BUT it is not visible in ANY way in the admin->orders.php interface?

 

Scott

Edited by olsonsp4c
Link to comment
Share on other sites

Yeah, I cant find the code I deleted in my older backups. It pretty much was an older version of this methods contrib. It was in the code commented by // Methods 3.0

 

Also, do you mean that the order is placed, it shows up in the database, BUT it is not visible in ANY way in the admin->orders.php interface?

Correct.

 

Ok, so I narrowed it down, and it seems that any order placed that uses a shipping figure provided by the USPS module is not visible in the orders.php page.

All my test orders placed using flat rate, table rate, or per item shipping modules show up just fine and normal. This leads me to believe that somewhere down the line some type of error/bug is introduced. Now, I may have missed a line of code somewhere, or it is interference with another contribution. I would like to reinstall the Methods contrib from the start, to unedited files.

 

Looking at the installation.txt file in the 4.3.0 contrib package, would I follow the 6 step install directions, the 9 step ones, or both?

 

Thanks again,

--Martin--

Link to comment
Share on other sites

Yeah, I cant find the code I deleted in my older backups. It pretty much was an older version of this methods contrib. It was in the code commented by // Methods 3.0

 

 

Correct.

 

Ok, so I narrowed it down, and it seems that any order placed that uses a shipping figure provided by the USPS module is not visible in the orders.php page.

All my test orders placed using flat rate, table rate, or per item shipping modules show up just fine and normal. This leads me to believe that somewhere down the line some type of error/bug is introduced. Now, I may have missed a line of code somewhere, or it is interference with another contribution. I would like to reinstall the Methods contrib from the start, to unedited files.

 

Looking at the installation.txt file in the 4.3.0 contrib package, would I follow the 6 step install directions, the 9 step ones, or both?

 

Thanks again,

--Martin--

 

If you are upgrading from a pre 3.0 version of usps, use the second set of instructions. if you are upgrading from a version from 3.0.1 but prior to 4.3.0, then you should follow the set of instructions if you are first set of instructions and then skip down to STEP 8 on the second set of instructions... that's my take, it is a little confusing. My guess is that you might have followed the first set of instructions and were upgrading from a pre-3.0 version initially so missed the addition to the modules.php file.

 

Scott

Edited by olsonsp4c
Link to comment
Share on other sites

I'm having a problem with this contribution.

 

Everything seems to be installing fine, but when I install the module and then edit the information, all the fields get replaced with the word "ARRAY" instead of displaying the information I edited.

 

Any thoughts?

 

never mind didn't update one of the files correctly... doh!

 

Ok, just went through and followed all install directions as noted. Now I am getting the same error as Archeon above did. I went through a second time and looked at all files and went through all the directions again, but I still am getting the "array" issue. Exactly what file wasnt edited correctly? Any suggestions as to where I should look?

 

Thanks,

--Martin--

Link to comment
Share on other sites

For anyone struggling with me, I have a little better behavior now. While I haven't fully tested, my changes appear to have worked. I took 4.1.4, followed the instructions up to here:

 

**********

* STEP 7 *

**********

 

Enable the USPS shipping module:

Go to the shipping module page, Admin -> Modules -> Shipping.

Click the green button next to United States Postal Service.

 

 

after this, I ran the following script:

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';

 

I can't promise this is exactly best solution...it just appears to be working for me which is why I thought I would offer for those similarly struggling as I was. Thanks.

Link to comment
Share on other sites

Not sure if I'm having an issue or if the USPS API system is... not sure where to look for system Status from USPS (if you even can)... when you click on Checkout in our 2 stores, it seems to hang for a while and do nothing. If I disable the USPS Methods (change Enable USPS Shipping to False in the Module from teh Admin tools), then it goes right on through to the 1st check out step. But I only use USPS for shipping, so no I have no shipping enabled... anyone else having an issue with the USPS API tonight or is it just my stores? Seems strange that both of my stores just started to act up at the same time.

 

thanks, Bryce

Link to comment
Share on other sites

Not sure if I'm having an issue or if the USPS API system is... not sure where to look for system Status from USPS (if you even can)... when you click on Checkout in our 2 stores, it seems to hang for a while and do nothing. If I disable the USPS Methods (change Enable USPS Shipping to False in the Module from teh Admin tools), then it goes right on through to the 1st check out step. But I only use USPS for shipping, so no I have no shipping enabled... anyone else having an issue with the USPS API tonight or is it just my stores? Seems strange that both of my stores just started to act up at the same time.

 

thanks, Bryce

 

I think it must be the USPS API... I finally had the page come up, but took about 3 minutes for it to open up the checkout_shipping.php page after clicking on the Checkout button.

Still.. is anyone else experiencing this?

 

Bryce

Link to comment
Share on other sites

I think it must be the USPS API... I finally had the page come up, but took about 3 minutes for it to open up the checkout_shipping.php page after clicking on the Checkout button.

Still.. is anyone else experiencing this?

 

Bryce

 

OK.. fixed it.. 4.1.4 went flaky... I went back to the original USPS that comes with OSCommerce and it was OK, so it wasn't the USPS Site or API... I went to teh $.3.0 Alpha and it appears to be working fine... and 4.3.0 has some nice new features.

Link to comment
Share on other sites

Seems like USPS server might be down... or they up and changed all the settings again. I've checked three stores on three different servers in the last few minutes and all are displaying the standard error message.

 

Anyone know or having the same issue?

 

Looks like we're having the same issue again

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