Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] - USPS Methods


Recommended Posts

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?

 

Leave the line.

 

find the two lines (in usps.php) with the email address [email protected] and replace all four of the addresses with your own. Uncomment the lines by removing the //. Go to your site checkout and test both domestic and international shipping. You should receive USPS responses to the email address that you enter. Change the email back and comment it again. You only need one test set.

 

Post the response(s) that you get. It will be a lot, and you might have to use a couple of posts to get it all. But that's the starting point to trying to pinpoint this.

 

If you are not receiving php errors, then it might not be the installation (code or sql). It might be a problem with communication. Those response emails will help determine if that's the problem. Also, check the troubleshooting tips in the install instructions.

Edited by fulluvscents
Link to comment
Share on other sites

I found another small, if not annoying, issue with the 5.2.1 update. I have another module for "Store Pickup" installed. The description in the language file is

 

"In-store pickup during regular business hours."

 

The problem is that the USPS changes are messing with all the descriptions that have the letters " reg" in them and turning them into the registered trademark symbol.

 

"No shipping charge added. Pickup during®ular business hours."

 

This would be simple to fix by changing the text from "regular" to "normal" in the language file. Fulluvscents, I know you are a stickler for doing this right. We should take a look at the changes to the checkout_shipping.php specifically $search = array(' reg', ' trade'); and everywhere else it shows up. and figure out how to isolate it even more. I'm not sure what the USPS response is that triggers this function, otherwise I'd play with it myself.

Link to comment
Share on other sites

usps sends <sup>®</sup> in urlencoded format. The problem is that even after this is decoded and replaced, I couldn't get it to strip the special characters for processing and posting the methods. It was more effective to modify it down to a common term and then do the replacement at the display level. This way we have both the function and the display working properly.

 

I replaced <sup>®</sup> with " reg" and the same thing for trade. It can be replaced with ANYTHING that doesn't contain special characters. I'll replace it with something else to ensure that it doesn't interfere with other modules.

 

Will post back when fix is uploaded

Link to comment
Share on other sites

new package was uploaded to contributions changing the replacement language and adding a couple things to instructions that were pointed out by other members.

 

Thanks

Link to comment
Share on other sites

Leave the line.

 

find the two lines (in usps.php) with the email address [email protected] and replace all four of the addresses with your own. Uncomment the lines by removing the //. Go to your site checkout and test both domestic and international shipping. You should receive USPS responses to the email address that you enter. Change the email back and comment it again. You only need one test set.

 

Post the response(s) that you get. It will be a lot, and you might have to use a couple of posts to get it all. But that's the starting point to trying to pinpoint this.

 

If you are not receiving php errors, then it might not be the installation (code or sql). It might be a problem with communication. Those response emails will help determine if that's the problem. Also, check the troubleshooting tips in the install instructions.

 

Thank you!

 

I got ten "USPS Transit Response" emails, and one "USPS Rate Quote response." All the emails are 0KB each. They are all blank or empty...no text, no code...nothing.

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

Link to comment
Share on other sites

Thank you!

 

I got ten "USPS Transit Response" emails, and one "USPS Rate Quote response." All the emails are 0KB each. They are all blank or empty...no text, no code...nothing.

 

The script sends you the response from USPS. If you sent a bad request, you would get an error response, but that isn't the case. You got no response, and chances are, it's because you aren't sending the request at all. The script is running, and you are able to send yourself emails, but your server is not communicating with the USPS server.

 

From the original troubleshooting tips: "If you don't receive any email after testing with this hook, that may indicate a failure in http socket handling on your server."

 

I think this goes beyond the script and honestly it's far beyond my scope of knowledge.

 

for s&g, comment out this code from modules.php and see what happens:

 

                          if( is_array( $value ) ){

         $value = implode( ", ", $value);

                         $value = ereg_replace (", --none--", "", $value);

                           }

 

Beyond that, I wouldn't know how to test or fix anything in regards to server issues.

Link to comment
Share on other sites

I am trying the new install (USPS Methods 5.2.1 - fix string replace), but I don't see this in 2.3.1:

9. If upgrading any previous version of "usps methods", modify the following and skip to line 13. If this is a new install, then skip this step and go onto step 10.

 

catalog/admin/includes/functions/general.php

 

Find:

 

// Alias function for Store configuration values in the Administration Tool

I don't recall modifying this file for the other install (USPS5.2.0-Threshold Fix). I am assuming this is a mod, not a new install, as I installed USPS5.2.0-Threshold Fix.

 

also this "find" is not in 2.3.1:

6. For stock checkout, modify the following (even if you have one page checkout):

 

catalog/checkout_shipping.php

 

Find:

<td class="main" width="75%"><?php echo $quotes[$i]['methods'][$j]['title']; ?></td>

its slightly different

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

Link to comment
Share on other sites

I am trying the new install (USPS Methods 5.2.1 - fix string replace), but I don't see this in 2.3.1:

 

I don't recall modifying this file for the other install (USPS5.2.0-Threshold Fix). I am assuming this is a mod, not a new install, as I installed USPS5.2.0-Threshold Fix.

 

also this "find" is not in 2.3.1:

 

its slightly different

 

If that line isn't in your general.php file then it's because you never added it and yes, you should have. That is why I changed the instructions. Having two sets of contradictory instructions was too confusing and made it easy to miss things.

 

Just go through the instructions. If you did not already add that section of code originally, then you need to go to the next instruction and add it as a new install. The following code should exist in your general.php file.

 

// 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++) {

       $search = array(' regimark', ' tradmrk');

       $replace = array('<sup>®</sup>', '<sup>™</sup>');

     $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 .= '> ' . str_replace($search, $replace,$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.

 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.

 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;

 }

 

Realistically it can go anywhere in the file, as long as it isn't in the middle of another function. I don't know about 2.3.1, but all the 2.2 functions are separated by two commented lines like this:

 

////
//

 

When you install or update your configuration from the admin panel, this is the code that tells it how to apply your options to the db. I'd be surprised if you didn't have this code and it didn't cause errors (like undefined function). But, if that is the case, then it would very easily explain why your module wasn't working - nothing was being put in the db.

Edited by fulluvscents
Link to comment
Share on other sites

As a matter of simplification, I just uploaded a full file drop for osc2.3.1. For anyone installing this into an UNMODIFIED OSC2.3.1 store, it is as simple as dropping the files into your catalog folder and following a couple of instructions. This will NOT work in any other OSC version, and is not recommended for modified 2.3.1 stores.

Link to comment
Share on other sites

usps sends <sup>®</sup> in urlencoded format. The problem is that even after this is decoded and replaced, I couldn't get it to strip the special characters for processing and posting the methods. It was more effective to modify it down to a common term and then do the replacement at the display level. This way we have both the function and the display working properly.

 

I replaced <sup>®</sup> with " reg" and the same thing for trade. It can be replaced with ANYTHING that doesn't contain special characters. I'll replace it with something else to ensure that it doesn't interfere with other modules.

 

Will post back when fix is uploaded

 

 

Thanks! Also, is there any way to get rid of the ® that shows up in the shipping method for the order confirmation emails that come through as plain text? For example:

 

United States Postal Service5 lbs, 0 oz (Priority Mail®--Approx. delivery time 3 Days--Insured for $21.35): $12.00

Link to comment
Share on other sites

Hey!

Im looking for a good usps shipping module....and this looks promising.

Does anyone have a link to some screenshots of this contribution in action? Maybe a "domestic/US" screenshot and an "international" screenshot?

Does anyone have the latest upload of this contribution working the way they want?

Are there many updates to the latest package that need to be made?

Any comments would be greatly appreciated.

 

Kurt

Link to comment
Share on other sites

As it stands, this is the ONLY module that conforms with the API changes, so it is your only option if you want your mod to work after May, 2011.

 

Known bugs or issues have been resolved in the latest uploads and any known conflict issues with other mods have also been resolved.

 

I will note that I need to fix an issue with international flat rate envelopes. I haven't had time to get to it and it isn't a huge functional problem as of yet. So, that fix will be uploaded when I get time to do it.

 

I have a dev cart at http://www.fulluvscents.com/store1. This is a copy of my regular site that I use for testing only. Feel free to test it out there. You will need to create an account and you can add international and domestic addresses. Unfortunately, there is no access to the admin panel and the scroll is too long to get a screen shot, so all I can offer from my end is a test site to play with.

Link to comment
Share on other sites

As it stands, this is the ONLY module that conforms with the API changes, so it is your only option if you want your mod to work after May, 2011.

 

Known bugs or issues have been resolved in the latest uploads and any known conflict issues with other mods have also been resolved.

 

I will note that I need to fix an issue with international flat rate envelopes. I haven't had time to get to it and it isn't a huge functional problem as of yet. So, that fix will be uploaded when I get time to do it.

 

I have a dev cart at http://www.fulluvscents.com/store1. This is a copy of my regular site that I use for testing only. Feel free to test it out there. You will need to create an account and you can add international and domestic addresses. Unfortunately, there is no access to the admin panel and the scroll is too long to get a screen shot, so all I can offer from my end is a test site to play with.

 

 

 

 

Thanx for the reply!

 

I dont offer too many shipping options just:

 

Media Mail

Prority Mail

and

First Class International

Priority Mail International

 

So hopefully i wouldnt have any problems.

 

What I am really looking for (besides a working store after May 2011) is a way to offer insurance to my customers as my products are prone to damage. I see in your cart you have many shipping options with their cost as well as an "insured for" quote. I chose a shipping option but then didnt see how to have it insured...maybe i missed it...i dont know.

I want my customers to be able to choose a shipping option THEN any corresponding insurance for that option...is this possible?

 

I thank you for your help!

 

Kurt

Link to comment
Share on other sites

Customer option is not available and I personally won't be the one to make it available. I know there are a lot of people who'd like to see a customer option for insurance, and maybe someone will finally do it, but it's beyond anything that I desire to get involved in. Customers have automatic insurance by virtue of consumer protection laws. They don't need to buy insurance to protect their purchase so giving them an option is opening a door that I don't want to open. Whether the buyer insures or not, the seller is responsible, regardless of disclaimers and terms (usually by virtue of the merchant credit card agreement). The seller is the one who has to decide whether or not to insure against his potential losses and in doing so, whether he wants to insure through USPS, self insurance, or increased product prices.

 

Personally, I charge for insurance on a per shipment basis and put it in a Fulluv Scents "lost" international first class mail fund. Yup, amazing how that's the only class of mail that gets lost.

Link to comment
Share on other sites

You fix that through your admin panel - configuration, emails, set mime html emails to true.

 

 

Well, duh...thanks, hadn't ever switched it over from text on any of my installations.

Link to comment
Share on other sites

Please PM me if you get the new USPS Methods Add On (http://addons.oscommerce.com/info/487/v,22) to work with 2.3.1.

 

Thanks

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

Link to comment
Share on other sites

Please PM me if you get the new USPS Methods Add On (http://addons.oscommerce.com/info/487/v,22) to work with 2.3.1.

 

Thanks

 

I installed a completely fresh 2.3.1 module and then installed USPS per instructions and it worked perfectly fine. I uploaded a full package of all files that were modified with the USPS install as a new contribution last week. I know that you mixed up instructions between the functions/general.php and the admin/functions/general.php files. Rather than sorting it out, it was easier for me to do a full upload that you can use to overwrite one file at a time until you find the overwrite any files that were incorrectly modified during your installation. If you upload that entire package and make the couple of necessary changes in your admin panel, and still have problems, then your issue is something beyond what I can help with. It could be something in a different file, a conflict with another contribution that hasn't already been mentioned, or a server issue. Whatever it is, it goes beyond the scope of compatibility between this module and the OSC version. It has been tested on osc2.3.1 by myself and others and it is working fine.

 

You need to either back up to the last known working file set (from before installing the USPS module) and start the USPS installation over from scratch, reinstall your OSC version from scratch and reinstall the USPS module from scratch, go back through the instructions carefully and manually find the error yourself and fix it, or find someone willing to access your files to assist you.

 

Beyond Compare is a file comparison program that can help you find differences between your files and stock osc files or the files that I modified (found in the latest contribution). It is a descent and easy to use program that comes with a free 30 day trial. It might prove to be very useful in finding your file conflicts. I would start with admin/includes/functions/general.php and admin/modules.php since the last problems you mentioned to me were in your admin panel.

Link to comment
Share on other sites

Hello. Is there any way that I can define the dimensions of flat rate boxes? I ship bulky lightweighted items and the box's dimensions are very important for me. Please advise.

 

Thanks.

Link to comment
Share on other sites

I'd like to change the names a bit of the shipping methods to reflect the max size of a flat rate box. When I change them they disappear from the available methods list from checkout_shipping.php.

 

I'm changing includes/modules/shipping/usps.php

 

'Priority Mail Int Flat Rate Small Box' => 'Priority Mail regimark International Small Flat Rate Box**',

 

to

 

'Priority Mail Int Flat Rate Small Box' => 'Priority Mail regimark International Small Flat Rate (max dim. 8-5/8" x 5-3/8" x 1-5/8")',

 

What am I missing here? Where do I need to make this change?

Link to comment
Share on other sites

Hello. Is there any way that I can define the dimensions of flat rate boxes? I ship bulky lightweighted items and the box's dimensions are very important for me. Please advise.

 

Thanks.

 

This module does not include any provisions for dimensional shipping. All settings are established by weight. You can turn flat rate boxes on and off though if you find that including them causes the cart to over/under charge.

 

 

I'd like to change the names a bit of the shipping methods to reflect the max size of a flat rate box. When I change them they disappear from the available methods list from checkout_shipping.php.

 

I'm changing includes/modules/shipping/usps.php

 

'Priority Mail Int Flat Rate Small Box' => 'Priority Mail regimark International Small Flat Rate Box**',

 

to

 

'Priority Mail Int Flat Rate Small Box' => 'Priority Mail regimark International Small Flat Rate (max dim. 8-5/8" x 5-3/8" x 1-5/8")',

 

What am I missing here? Where do I need to make this change?

 

If your value doesn't match the response from USPS, then you will not get the rate response. In other words, you can't change it unless you manually do a string replace at the display level like we did with changing regimark to <sup>®</sup>. You can't change the value in the module. You have to recode it in the display pages. If you follow through the install instructions and chase the code added for the regimark displays, then you could add new code to each of those pages, for EACH string of text that you want to replace. Change the following:

 

		$search = array(' regimark', ' tradmrk');
       $replace = array('<sup>®</sup>', '<sup>™</sup>');

 

TO

 

 

		$search = array(' regimark', ' tradmrk', 'STRING TO REPLACE', 'STRING TO REPLACE', 'STRING TO REPLACE');

       $replace = array('<sup>®</sup>', '<sup>™</sup>', 'NEW STRING', 'NEW STRING', 'NEW STRING');

 

'STRING TO REPLACE' would be Small Flat Rate Box**, Medium Flat Rate Box, Large Flat Rate Box, etc.

'NEW STRING' would be Small Flat Rate (max dim. 8-5/8" x 5-3/8" x 1-5/8"), with medium, large, etc added in the same manner.

Edited by fulluvscents
Link to comment
Share on other sites

So, I finally got it to work! occasion14.gif

 

Problem was on my host's side...a port issue.

Edited by ErikMM

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

Link to comment
Share on other sites

I have had no problem with those choices with an older osc, the new 2.3.1 or oscmax please check your install - something is missing somwhere

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

Link to comment
Share on other sites

I have had no problem with those choices with an older osc, the new 2.3.1 or oscmax please check your install - something is missing somwhere

 

I can't imagine what.....it is rather specific to just the International Flat Rate envelopes and First Class International Large Envelope. Domestic is fine, all other choices work well.

 

And I am not the first person to note that they are missing - there was a post on January 26th in this thread that reported the same issue.

 

I am using OSC 2.2.

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