Jump to content



Photo
* * * * * 1 votes

USPS Rate V4, Intl Rate V2 (official support thread)


  • Please log in to reply
1207 replies to this topic

#1   fulluvscents

fulluvscents
  • Members
  • 305 posts
  • Real Name:Jetta
  • Gender:Female
  • Location:Fort Wayne, Indiana

Posted 31 January 2012 - 10:26

I will be uploading a new USPS module shortly.

This is a very simple module, with no bells and whistles, except that you can choose the allowable shipping methods.
I know that some people wanted that, and it is available now.

The script is completely updated, with proper use of XML data, and better (less intrusive) fixes to the html characters than what were previously done.

USPS methods eventually got to over 1000 lines of very inefficient code and required modifications to half a dozen pages. This script is under 200 lines of code, and requires only 3 modifications in 2 pages.

Even if/when all the bells and whistles are applied to this code, it should require less than half the coding and strain as USPS Methods.

A link to the contribution will be uploaded shortly. I needed to get a forum thread going first, so that it could be included with the contrib.

Jetta

#2   fulluvscents

fulluvscents
  • Members
  • 305 posts
  • Real Name:Jetta
  • Gender:Female
  • Location:Fort Wayne, Indiana

Posted 31 January 2012 - 11:37

Contribution can be found here:

http://addons.oscommerce.com/info/8327

#3   hughesca

hughesca
  • Members
  • 134 posts
  • Real Name:Chris Hughes

Posted 31 January 2012 - 16:39

Hey there fulluvscents!

I just finished installing your module and LOVE the simplicity of it. The installation was simple and it works smoothly.

However, I do have one bug I can't seem to resolve. It's not showing rates for First-Class Mail Int'l Parcel.

Here are a few options I would like to see, I think they are all the module would ever need.

1. Define handling fee for either domestic or international, instead of both with one value.
2. Ability to require insurance for either domestic or international and add such fees at checkout.

With the above options, I would absolutely switch to this module!

Peace,
PHRoG

#4   pederb

pederb
  • Members
  • 448 posts
  • Real Name:Peder
  • Gender:Male
  • Location:Oakland, CA

Posted 31 January 2012 - 19:01

Sounds great, my 2.3.1 is kind of scewed up since version 6.01 does not really support 2.3.1

How should I proceed?
-Peder Beckman-
Kool Kat Jazz Records

#5   hughesca

hughesca
  • Members
  • 134 posts
  • Real Name:Chris Hughes

Posted 31 January 2012 - 19:10

When I tested it I also had 6.1 installed. Getting rid of that and installing this was easy.

Uninstall USPS from the admin under Modules > Shipping.

Upload the files under New Files and make the 3 modifications to your existing files as found in the instructions.

Once complete, just go back to Modules > Shipping, click install and choose USPS.

Then edit the module, insert your USPS ID, selection your shipping options and specify a handling fee if any.

Viola, your done!

Hope that helps,
Chris

#6   pederb

pederb
  • Members
  • 448 posts
  • Real Name:Peder
  • Gender:Male
  • Location:Oakland, CA

Posted 31 January 2012 - 22:47

Getting this error messsage

Deprecated: Function ereg_replace() is deprecated in /home/wihirt/public_html/catalog/******/modules.php on line 47

Warning: Cannot modify header information - headers already sent by (output started at /home/wihirt/public_html/catalog/******/modules.php:47) in /home/wihirt/public_html/catalog/******/includes/functions/general.php on line 34

Also First Class Intenational is not working either?

Edited by pederb, 31 January 2012 - 22:55.

-Peder Beckman-
Kool Kat Jazz Records

#7   hughesca

hughesca
  • Members
  • 134 posts
  • Real Name:Chris Hughes

Posted 31 January 2012 - 22:56

That's because you have the one in there from USPS Methods still. Search general.php for ereg_replace() and remove the function that you entered when you installed USPS Methods.

Peace,
Chris

#8   pederb

pederb
  • Members
  • 448 posts
  • Real Name:Peder
  • Gender:Male
  • Location:Oakland, CA

Posted 31 January 2012 - 23:24

i checked general.php in admin but such text in it?

Edited by pederb, 31 January 2012 - 23:26.

-Peder Beckman-
Kool Kat Jazz Records

#9   hughesca

hughesca
  • Members
  • 134 posts
  • Real Name:Chris Hughes

Posted 01 February 2012 - 03:24

i checked general.php in admin but such text in it?


You should use a text editor or html editor to modify the file. You'll find it here: catalog/<your admin directory)/includes/functions/general.php.

#10   pederb

pederb
  • Members
  • 448 posts
  • Real Name:Peder
  • Gender:Male
  • Location:Oakland, CA

Posted 01 February 2012 - 19:01

I use Dreamweaver
-Peder Beckman-
Kool Kat Jazz Records

#11   fulluvscents

fulluvscents
  • Members
  • 305 posts
  • Real Name:Jetta
  • Gender:Female
  • Location:Fort Wayne, Indiana

Posted 02 February 2012 - 15:01

I have uploaded a couple more versions - and will continue to do so until I have the module where I personally want it. I figure it'll be nice to give different options because not everybody has the same shipping needs.

Some of the int'l options weren't showing up in 1.0 b/c of the dimensions (first class was fine. It was flat rate boxes that I wasn't getting). It took a bit of playing to find dimensions that returned all packages, but I did find them and they are set up in v1.1 - that means that you do not need to set dimensions from the admin panel, like with previous versions (less clutter).

Everyone, please note, that in order for the module to work, you must uninstall the old version before installing the new one. Otherwise, you'll end up with junk configurations that will interfere with the new module. To remove them, you either need to put the old file back and reinstall/uninstall, or manually search and remove all USPS entries from your configuration table in your database.

This module is NOTHING like the old ones. The scripting is entirely different. The html character replacements are different. There may even be straggling code in other files that you are free to remove once you install this. I have two goals when scripting now. 1. Do not intrude on the core project unless that is the actual intent of the add on, and 2. Efficiency. What was taking over 1000 lines of code, can be done in less than 300. Less redundant script means less crap for your server to read through, faster page loads, etc...

My hope is to get in the options, without cluttering the admin panel. One script can't meet everybody's needs without becoming too much. So, I'll hit the basic needs, and the stuff that I personally want. I suspect, working on it here and there, I'll have that done within a week or so.

@ Pederb - I do not have one single ereg_replace function in this script. So, you're getting that from somewhere else. You do need to remove the functions that were installed with the prior USPS modules. They are not necessary. So far, only ONE tep function is required for what I've got written. The rest can be removed (in both catalog functions, and admin functions). You just have to locate them.

I don't know that dreamweaver can be used as a text compare tool without downloading/integrating other applications. That being the case, it makes sense to use a standalone text compare tool. I personally use beyond compare. Winmerge is a popular free tool.

Anybody who is going to be installing / uninstalling, or modifying files, NEEDS to have a compare tool. It is so much easier and faster than going through instructions line by line. I don't like writing instructions any more than I like reading or following them. So, you'll find that my contributions won't include them unless it's a real simple install. And even if they do, it might not be completely "accurate". But one thing I will always do is mark any changes in comments like this // EXAMPLE START ...... // EXAMPLE END. I will comment out old lines and not comment new lines. Changes will be easy to find and easy to undo.

#12   fulluvscents

fulluvscents
  • Members
  • 305 posts
  • Real Name:Jetta
  • Gender:Female
  • Location:Fort Wayne, Indiana

Posted 06 February 2012 - 17:27

Just uploaded some upgrades. Separate handling fees for each shipping method, insurance (and any other available extra service), and ability to show shipping regulations to international customers. This will be most beneficial for those running 2.3.1 shops, but will also work on 2.2 shops. The older shops just won't be able to show extra services or regulations.

Despite the fact that it does take up some room in admin (due to the large number of shipping methods, it is tucked into a nice neat little package, isn't sloppy, and should not be confusing.

#13   pederb

pederb
  • Members
  • 448 posts
  • Real Name:Peder
  • Gender:Male
  • Location:Oakland, CA

Posted 06 February 2012 - 20:14

Hi Jetta,

The new version works great, but insurance options are showing up?

Not a biggie for me do

Cheers
-Peder Beckman-
Kool Kat Jazz Records

#14   32 Degrees

32 Degrees
  • Members
  • 233 posts
  • Real Name:Ryan
  • Gender:Male
  • Location:California, USA

Posted 07 February 2012 - 07:20

Jetta,

Thanks for taking the time to release this contribution! I installed it today and wanted to give you some feedback. This contribution as well as other shipping modules needs updated instructions on the admin/modules.php for the dynamic template contribution commonly found on TemplateMonster shops. I will post them here once I have figured out a solution.

Additionally, I think I may have uncovered a bug in the usps.php shipping class. That is, a minimum of two usps shipping options are required for the module to display anything. For example, if I only want to offer priority mail then the module doesn't display any options. However, if I offer priority mail and medial mail, both options will display.


Just some more cents to add to your collection /smile.png' class='bbc_emoticon' alt=':)' />

- Ryan
[IMG]http://img263.imageshack.us/img263/4146/plasma.jpg[/IMG]

#15   fulluvscents

fulluvscents
  • Members
  • 305 posts
  • Real Name:Jetta
  • Gender:Female
  • Location:Fort Wayne, Indiana

Posted 07 February 2012 - 13:27

If the dynamic template requires changes to the shipping mods, then perhaps, the dynamic templates should either be rewritten, so that they don't intrude on already existing scripts, or the dynamic templates contributor(s) should take the time to supply the necessary updates for the mods that their script intrudes on, don't you think? If they can't make it a one size fits all, then they need to invest the time in staying up to date with CORE mods and issuing compatibility packets along the way. Seems to me it would be easier (and make more sense) to write a script that works with the existing OSC core, than it does to force changes to the core and all surrounding mods so that an incompatible contribution will fit like it would if it had been written thoughtfully in the first place. Incompatibility of another contribution isn't a shipping mod issue. It's a distinct issue that needs to be dealt with by the creator of that contribution. Those are my cents on that.

The issue with needing to choose 2 shipping methods is in fact a bug. I've found the reason and fixed that and I will upload a new package momentarily.

@pederb

I'm not sure what you mean. First I need to mention that this isn't the old USPS methods. The option isn't to display insurance as text just to inform the customer that their package is insured, but rather to display any add on services as a break down of the total cost, if you choose to display it.

Your choice is to:

1. Not use the service
2. Use the service (which the customer pays for), bundle it into the cost of the shipping methods, and NOT SHOW the customer a breakdown of their shipping costs.
3. Use the service (which the customer pays for), bundle it into the cost of the shipping methods, and SHOW the customer a breakdown of their shipping costs.

For option three, before the breakdown will be displayed, the customer must choose a shipping option. Once the option is selected, they will see (Show Details). When they click on that, it will give them a breakdown (base, handling, delivery confirmation, insurance, etc...). The page gets far too sloppy if you display everything at once. So, it is only displayed on an as needed/wanted basis.

Just because you choose an option, does not mean it will be available, or that it will be charged, hidden or displayed. If USPS doesn't offer the service for whatever reason, then your selection is moot.

USPS may not offer a service for a variety of reasons:
a. Value exceeds insurable value
b. Service is only available at counter and you chose internet rates, or vice versa
c. Service not available for shipping type
d. Service is not available to destination country
e. etc......

If you choose it, and IF USPS returns it, then it will be charged and added (and displayed if you choose to display it). This module is based strictly on what USPS offers, based on the input that comes from your cart and your admin settings. It isn't designed to be custom suited for anything outside of USPS package options and services.

Another point that I need to make. The script pulls ALL available information and sorts/charges/displays based on what you give it. If you choose two services that are redundant or incompatible per USPS offerings, both of those services will be returned. It's up to you to know what is and isn't appropriate for your shop and your customers. For example, don't choose "registered mail without insurance" PLUS insurance, or vice versa, don't choose regular registered mail, but forget to choose insurance along with it. And there is no sense in displaying both delivery confirmation AND signature confirmation, as these are redundant and SC rules out DC.

#16   Dennisra

Dennisra
  • Members
  • 515 posts
  • Real Name:Joseph D. Jefferson
  • Gender:Male

Posted 07 February 2012 - 19:11

Is there a test site or does someone have this installed where it can be viewed and tired. It sounds great!

#17   fulluvscents

fulluvscents
  • Members
  • 305 posts
  • Real Name:Jetta
  • Gender:Female
  • Location:Fort Wayne, Indiana

Posted 07 February 2012 - 20:49

Sure, I've got it installed here:

http://www.fulluvscents.com/catalog.

The checkout isn't stock. It's a brand spanking new single page checkout, but the options work exactly the same in stock checkout. Unfortunately though, you won't be able to get into the admin area.

I am presently adding a few more thing to it, so if things get wacky, that will be why.

#18   32 Degrees

32 Degrees
  • Members
  • 233 posts
  • Real Name:Ryan
  • Gender:Male
  • Location:California, USA

Posted 08 February 2012 - 01:35

If the dynamic template requires changes to the shipping mods, then perhaps, the dynamic templates should either be rewritten, so that they don't intrude on already existing scripts, or the dynamic templates contributor(s) should take the time to supply the necessary updates for the mods that their script intrudes on, don't you think? If they can't make it a one size fits all, then they need to invest the time in staying up to date with CORE mods and issuing compatibility packets along the way. Seems to me it would be easier (and make more sense) to write a script that works with the existing OSC core, than it does to force changes to the core and all surrounding mods so that an incompatible contribution will fit like it would if it had been written thoughtfully in the first place. Incompatibility of another contribution isn't a shipping mod issue. It's a distinct issue that needs to be dealt with by the creator of that contribution. Those are my cents on that.


Jetta,

Thanks for taking some time to fix the bug in the USPS class, I really appreciate it! As of today the contribution is running as desired /smile.png' class='bbc_emoticon' alt=':)' />

In regards to the dynamic template system (DTS) I didn't do justice in explaining the issue thoroughly. I agree with your point that an intruding script should be maintained by it's author if it changes another contribution or affects core usage. In this situation it is not the case that the DTS intrudes on the USPS module, but, that each contribution attempts to process the information differently. In admin/modules.php the USPS contribution implodes $value if is_array($value) returns true, whereas, the DTS contributions incorporates it's own processing if is_array($value) is true.

I have seen many contributions with additional instructions to help users complete common tasks both big and small. For example, many contributions include separate instructions for the STS contribution. Being consistent with this idea would provide a great benefit to more users and foster a stronger community. As a resource to others I am going to post the changes I made here. I hope you would consider including them as additional instructions in future releases.

/smile.png' class='bbc_emoticon' alt=':)' />

- Ryan

P.S. I'm requesting the same of the DTS author.
[IMG]http://img263.imageshack.us/img263/4146/plasma.jpg[/IMG]

#19   32 Degrees

32 Degrees
  • Members
  • 233 posts
  • Real Name:Ryan
  • Gender:Male
  • Location:California, USA

Posted 08 February 2012 - 01:46

IF... You are having troubles incorporating this contribution within a shop using the Dynamic Template System these changes may solve your problem. They solved maybe they can solve yours?

admin/modules.php

FIND:
case 'save':
		reset($HTTP_POST_VARS['configuration']);
		while (list($key, $value) = each($HTTP_POST_VARS['configuration'])) {
		// bof Dynamic Template System			
		  if((is_array($value)) && (!empty($value))){
		  $pages = '';
		  $count = count($value);
		  for($i=0 ; $i<$count; $i++){
		  $pages = "$pages$value[$i]";
		  tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $pages . "' where configuration_key = '" . $key . "'");
			   }
		  }
		// eof Dynamic Template System
		  else
		  {		
		  tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $value . "' where configuration_key = '" . $key . "'");
		  }
		}
		tep_redirect(tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $HTTP_GET_VARS['module']));
		break;

REPLACE:
case 'save':
		reset($HTTP_POST_VARS['configuration']);
	foreach($_POST['configuration'] as $key => $value) {		
		   // Dynamic Template System  
	 if((is_array($value)) && (!empty($value))) {
			  if (isset($set) && $set == "boxes") {
	   $pages = '';
	   $count = count($value);
	   for($i=0 ; $i<$count; $i++) {
		$pages = "$pages$value[$i]";
		tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $pages . "' where configuration_key = '" . $key . "'");
	   }
	  } else {
	   // USPS
	   $value = implode( ", ", $value);
	   tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $value . "' where configuration_key = '" . $key . "'");
	  }
	 } else {
	  tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $value . "' where configuration_key = '" . $key . "'");
	 }
	}
		tep_redirect(tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $HTTP_GET_VARS['module']));
		break;

FIND:
$contents[] = array('text' =>  $file);

REPLACE:
$contents[] = array('text' => '<br />' . preg_replace(array('/RM/', '/TM/', '/International/', '/Envelope/'), array('&reg;', '&trade;', 'Int\'l', 'Env'), $file)); // Modified for USPS

Good luck /wink.png' class='bbc_emoticon' alt=';)' />

Edited by 32 Degrees, 08 February 2012 - 01:48.

[IMG]http://img263.imageshack.us/img263/4146/plasma.jpg[/IMG]

#20   32 Degrees

32 Degrees
  • Members
  • 233 posts
  • Real Name:Ryan
  • Gender:Male
  • Location:California, USA

Posted 08 February 2012 - 01:53

Jetta,

Thanks again for releasing this contribution, it's a huge help! I wanted to point out some errors I encountered to see if you or others are having them as well? As they are E_NOTICE errors it doesn't seem to affect functionality from what I can see.

Error: Undefined variable: FirstClassMailType
File: includes/modules/shipping/usps.php
Line: 211
Error: Undefined index: Error
File: includes/modules/shipping/usps.php
Line: 82
Error: Undefined index: Certificate of Mailing
File: includes/modules/shipping/usps.php
Line: 86
Error: Undefined index: Registered MailTM
File: includes/modules/shipping/usps.php
Line: 86
Error: Undefined index: Registered without Insurance
File: includes/modules/shipping/usps.php
Line: 86
Error: Undefined index: Certified MailRM
File: includes/modules/shipping/usps.php
Line: 86
Error: Undefined index: Delivery ConfirmationTM
File: includes/modules/shipping/usps.php
Line: 86
Error: Undefined index: Return Receipt for Merchandise
File: includes/modules/shipping/usps.php
Line: 86
Error: Undefined index: Signature ConfirmationTM
File: includes/modules/shipping/usps.php
Line: 86
Error: Undefined index: Adult Signature Required
File: includes/modules/shipping/usps.php
Line: 86
Error: Undefined index: Adult Signature Restricted Delivery
File: includes/modules/shipping/usps.php
Line: 86
Error: Undefined index: Collect on Delivery
File: includes/modules/shipping/usps.php
Line: 86
Error: Undefined variable: iInfo
File: includes/modules/shipping/usps.php
Line: 160
Error: Undefined index: shownString
File: checkout_shipping.php
Line: 313

- Ryan
[IMG]http://img263.imageshack.us/img263/4146/plasma.jpg[/IMG]