Jump to content
bad_lemming

[Contribution] - USPS Methods

Recommended Posts

well it really is quite possible the module is that old, is it working?? I bet it's not. I suggest you move along and just install 5.2.0 :)

 

Make sure you follow all the steps.. check to see if the lines were added to ALL the files needed or you will have trouble.

 

Thanks again wkdwch. It was working, very well, until Jan 02 rolled around, and then I stopped getting quotes for international shipping. Maybe I just got one that nobody bothered to put what version it is on the usps.php page. Now, as far as checking the lines to see if they were added, is the 5.2 version not complete?

 

Thanks so much, wkdwch!!

 

 

 

Share this post


Link to post
Share on other sites

It is complete - just make sure you get the latest version with the weight threshold fix. What she was saying was to make sure to follow the install instructions and don't miss any of the code that needs to be added to your existing files. The usps.php files are overwrites with no coding on your part. Other files need to be manually modified by you. The package includes detailed instructions.

 

Thanks again wkdwch. It was working, very well, until Jan 02 rolled around, and then I stopped getting quotes for international shipping. Maybe I just got one that nobody bothered to put what version it is on the usps.php page. Now, as far as checking the lines to see if they were added, is the 5.2 version not complete?

 

Thanks so much, wkdwch!!

Share this post


Link to post
Share on other sites

It is complete - just make sure you get the latest version with the weight threshold fix. What she was saying was to make sure to follow the install instructions and don't miss any of the code that needs to be added to your existing files. The usps.php files are overwrites with no coding on your part. Other files need to be manually modified by you. The package includes detailed instructions.

 

 

 

Thanks fulluvscents. And a big thanks for all the hard work you've done! You're help has really made a great contribution to oscommerce!

 

Jason

Share this post


Link to post
Share on other sites

Hey Everybody. I tried to implement the new USPS Methods V.5.2.0 and I'm getting this fatal error:

 

Fatal error: Cannot redeclare tep_cfg_select_multioption() (previously declared in /****/****/*****/admin/includes/functions/general.php:812) in/*****/*****/*****/admin/includes/functions/general.php on line 886

I **** out the info that I've seen others do on this forum.

Any ideas why this is happening?

Thanks so much. I really don't have an admin that I use at the moment, so anybody who could help would be greatly appreciated!

jason

Share this post


Link to post
Share on other sites

Hey Everybody. I tried to implement the new USPS Methods V.5.2.0 and I'm getting this fatal error:

 

Fatal error: Cannot redeclare tep_cfg_select_multioption() (previously declared in /****/****/*****/admin/includes/functions/general.php:812) in/*****/*****/*****/admin/includes/functions/general.php on line 886

I **** out the info that I've seen others do on this forum.

Any ideas why this is happening?

Thanks so much. I really don't have an admin that I use at the moment, so anybody who could help would be greatly appreciated!

jason

 

Check your admin/includes/functions/general.php file. It looks like you've got the same code duplicated on line 812 and line 886. In other words, you added it per instructions, but it was already previously added - remove the duplicate and keep the most recent one. You might want to double check the modules.php and the catalog/includes/functions/general.php files too. If you doubled up on one, then chances are the added code already existed in the other two files as well. Guess your usps module was a newer version than you thought.

 

// USPS Methods - credit to Greg Deeth
 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;
 }
 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;
 }
 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;
 }

Share this post


Link to post
Share on other sites

Check your admin/includes/functions/general.php file. It looks like you've got the same code duplicated on line 812 and line 886. In other words, you added it per instructions, but it was already previously added - remove the duplicate and keep the most recent one. You might want to double check the modules.php and the catalog/includes/functions/general.php files too. If you doubled up on one, then chances are the added code already existed in the other two files as well. Guess your usps module was a newer version than you thought.

 

// USPS Methods - credit to Greg Deeth
 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;
 }
 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;
 }
 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;
 }

 

Thanks so much fulluvscents!! When i go to line 886 in the general.php file stated in the error, it has to do with my UPSXML part of the code. Is USPS Methods not compatible with the UPS contribution?

 

 

 

Share this post


Link to post
Share on other sites

Thanks so much fulluvscents!! When i go to line 886 in the general.php file stated in the error, it has to do with my UPSXML part of the code. Is USPS Methods not compatible with the UPS contribution?

 

The error is that you are defining the function (tep_cfg_select_multioption) twice. I don't use UPS, so I'm not sure about the difference between how UPS and USPS define the function. Hopefully, they are defined the same. If so, then just remove one of the definitions. If not, then post the UPS definition so that we can figure out how to merge the two and keep them from trying to override one another.

Share this post


Link to post
Share on other sites

The error is that you are defining the function (tep_cfg_select_multioption) twice. I don't use UPS, so I'm not sure about the difference between how UPS and USPS define the function. Hopefully, they are defined the same. If so, then just remove one of the definitions. If not, then post the UPS definition so that we can figure out how to merge the two and keep them from trying to override one another.

 

 

OK, this is the part that was in the error:

 

 

// UPSXML

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

}

 

 

Share this post


Link to post
Share on other sites

The function declaration is exactly the same. Just remove one (it doesn't matter which one) and you should be good to go.

 

It worked fulluvscents!! I just commented out the UPSXML info. Thanks so much!!

 

Jason

 

 

 

Share this post


Link to post
Share on other sites

Another error bites the dust. Thanks for posting and I'm glad to help you resolve it. Now others using both UPS and USPS will know to remove the duplicate code. Let us know if you run into any other problems.

Share this post


Link to post
Share on other sites

Another error bites the dust. Thanks for posting and I'm glad to help you resolve it. Now others using both UPS and USPS will know to remove the duplicate code. Let us know if you run into any other problems.

 

 

Thanks again, will do!!

 

 

Share this post


Link to post
Share on other sites

Wow, what a great contribution! Such awesome functionality!

 

I just have one issue. The approximate delivery dates don't seem to be too accurate. When I log into my site using my local address, the speed at which the package is quoted as arriving is fastest using first class mail and slowest using express mail. When I log into an account where the address in 3000 miles away, all of the arrival dates are the same regardless of which type of service I use; first class, priority, or express mail. When I checked this against the USPS site, there is a difference in speed in those three services. Has anybody else experienced this? Is there a way to change this? Also, when I change "days to process order", it doesn't have an effect on the "approximate delivery time". Maybe it's something I did when I installed it?

 

Thanks so much for any and all input!!

 

This really is a great contribution!!

 

Jason

Share this post


Link to post
Share on other sites

Wow, what a great contribution! Such awesome functionality!

 

I just have one issue. The approximate delivery dates don't seem to be too accurate. When I log into my site using my local address, the speed at which the package is quoted as arriving is fastest using first class mail and slowest using express mail. When I log into an account where the address in 3000 miles away, all of the arrival dates are the same regardless of which type of service I use; first class, priority, or express mail. When I checked this against the USPS site, there is a difference in speed in those three services. Has anybody else experienced this? Is there a way to change this? Also, when I change "days to process order", it doesn't have an effect on the "approximate delivery time". Maybe it's something I did when I installed it?

 

Thanks so much for any and all input!!

 

This really is a great contribution!!

 

Jason

 

The module is designed to display responses directly from USPS - and ADD the processing time (an integer) to the integer received from USPS. If the response is stated as "overnight to most areas", then it adds processing time to 1. If it comes back as a date, hmmmm, I don't know how it affects that. USPS never sends me a date - even though it sends everyone else dates. processing time will not affect international because USPS doesn't send an integer for international and you can't mathematically add an integer to a text phrase.

 

Did you uninstall the old module BEFORE you uploaded the new files? There may be a conflict with the old entries in your configuration table. If you uninstalled it AFTER you changed the usps.php file, then the old entries weren't removed from your configuration table. You will need to uninstall the module, remove every USPS entry in your configuration table and then reinstall the module. That is the only thing that I can think of which would affect the transit times - your module is pulling quotes based on bad inputs coming from your configuration table.

 

If you need help with removing the old configuration entries, just post back for instructions.

Share this post


Link to post
Share on other sites

I'm sure someone will supply a simple USPS module without all the bells and whistles - but I wanted the bells and yeah, the whistles too.

 

BIG bells and BIG whistles...I had no idea...holy crap this is way better than the 2.3.1 stock USPS module. Damn...I'm still prying my foot from my mouth.

 

It's all good in admin, but its not working. I am hoping its because I am not using the production server yet. I put in a request to get off the test server and will find out soon.

 

 

A BIG thanks for the BIG bells and whistles!


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

Share this post


Link to post
Share on other sites

BIG bells and BIG whistles...I had no idea...holy crap this is way better than the 2.3.1 stock USPS module. Damn...I'm still prying my foot from my mouth.

 

It's all good in admin, but its not working. I am hoping its because I am not using the production server yet. I put in a request to get off the test server and will find out soon.

 

 

A BIG thanks for the BIG bells and whistles!

 

It won't work unless you're on the live server. So far, I haven't heard of any script bugs with any version of osc, so you shouldn't have any problems.

Share this post


Link to post
Share on other sites

I just uploaded a new package (5.2.1). This includes the fix for the trademark legends. USPS sends them because they want them shown. It is required by their terms. I doubt they'll shut anyone's API down, but I'm not willing to take that chance.

 

I also noticed that the response time for USPS wasn't working correctly. If set to over 2 days processing time, it was shutting causing errors. I've never tested over 3 days, so I didn't catch it before. This package also includes the fix for that and removes a line of code from the original script which is no longer needed.

Share this post


Link to post
Share on other sites

I have installed Jetta's latest and greatest on my dev cart and all is just just about fine, resolved the issues and thought I would share..

 

If upgrading from any version check to see if you have any of the changes already installed in the appropriate files, I suggest a good text editor or comparison program

 

Make sure you change in

/catalog/includes/application_top.php

the timezone location using the link provided in the readme

---- however ----

I did not need that statement, so if you get an error after uploading

Fatal error: Call to undefined function: date_default_timezone_set() in /home/YOURWEBSITE_USER_NAME/public_html/catalog/includes/application_top.php on line 14

simply comment out the line

// set default store time zone
//date_default_timezone_set('America/New_York');

upload again and see if the error goes away. As Jetta explained it, my php.ini most likely has that information in there.

 

Next.. if you are using BTS or STS, oscMAX or whatever, steps 5 and/or 6

 

Find:

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

will be located somewhere else, in my case (oscMAX that uses BTS) it was in

/catalog/templates/fallback/content/checkout_shipping.tpl.php

also in the /content folder of my other templates, so check there

 

watch your <td class="main" there also, as mine was also different from whats in the readme (<td class="mainContent")

Edited by wkdwich

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

Share this post


Link to post
Share on other sites

Find:

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

will be located somewhere else, in my case (oscMAX that uses BTS) it was in

/catalog/templates/fallback/content/checkout_shipping.tpl.php

also in the /content folder of my other templates, so check there

 

watch your <td class="main" there also, as mine was also different from whats in the readme (<td class="mainContent")

 

YIKES. That was my bad. The default class is main. I have heavily modified my css and the class in my files is mainContent. I didn't catch that. Suppose I should modify the instructions. But, if someone else would like to do that before I find the time, then by all means - just make sure to upload as a full package. Single file uploads get messy and confusing. Thanks for catching that wckd

Share this post


Link to post
Share on other sites

How about just revising the readme Jetta?


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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

This is an awesome contribution and I have everything working including the trademarks, but for some reason, when I do a shipping estimate, the reg shows up instead of the register mark. Does anyone know how to fix this so I can be 100% compliant.

 

Thanks!

Share this post


Link to post
Share on other sites

This is an awesome contribution and I have everything working including the trademarks, but for some reason, when I do a shipping estimate, the reg shows up instead of the register mark. Does anyone know how to fix this so I can be 100% compliant.

 

Thanks!

 

Instructions are for stock osc sites with normal checkout or one page checkout (since that's what I have). I couldn't hit on every possible mod that might show the shipping methods since I imagine there are plenty of them out there.

 

To fix the "reg" and turn it into the trademark legend, find the code that displays the shipping method and modify the code like you did in the checkout_shipping page.

 

Anywhere on your site if you have the code:

 

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

 

it'll need to be replaced with:

 

<?php
       $search = array(' reg', ' trade');
       $replace = array('<sup>®</sup>', '<sup>™</sup>');
?>
                   <td class="main" width="75%"><?php echo str_replace($search, $replace, $quotes[$i]['methods'][$j]['title']); ?></td>

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

For those of you that want to make Shipping Estimator show the Marks:

 

Around line 740 of shipping_estimator.php

 

Find:

 

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

 

Replace with:

 

<?php
$search = array(' reg', ' trade');
       $replace = array('<sup>®</sup>', '<sup>™</sup>');
?>

                       <td class="main" width="75%"><?php echo str_replace($search, $replace, $method_data['title']); ?></td>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×