Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] - USPS Methods


Recommended Posts

Hi there. I can't seem to get the insurance options. To make a long story short, the shop i just installed had (I believe) the oldest version of this module pre-installed. So, after I enabled it, I had the recent issue where only express shipping was being picked in the final checkout...so i needed to upgrade. After much trial and error and making a frankenstien of different updates, I believe I have the two main usps files running from "METHODS 4.1.2 (with insurance 3.0).

On the admin panel, when I click the modules edit button, it is preceded by

Parse error: syntax error, unexpected T_GLOBAL, expecting ')' in /home/kintatzo/public_html/catalog/admin/modules.php(216) : eval()'d code on line 1 (but I can make changes)

Note 1: I DO get express, priority, and postal available..that's it. (Furthest i've tested is from NY to FL, so these may be the only options I can get?...I will try other addresses and test further) But I think I should be able to get insurance at that distance?

Note 2: My objective is to get US and Iternational...cheapest rates(ground, whatever)...with insurance optional

Thanks

Link to comment
Share on other sites

sorry didn't see the part in the readme that says:

If you are getting a "parse error" when you click edit in the admin OR

your international options with checkboxes are not showing up in the admin,

you may need to use phpMyAdmin to update the database -> configuration TABLE

and CHANGE "set_function" to TEXT from VARCHAR.

 

all is well now

Link to comment
Share on other sites

***** WARNING WARNING!! ********

 

 

One of my customers got a really good deal with a domestic EXPRESS quote: $17.88 instead of $68.58 for a 15 pound order :-)

 

in the usps.php file, line 274:

 

$this->container = 'FLAT RATE ENVELOPE'; //OPTIONS: 'VARIABLE', 'FLAT RATE ENVELOPE'

 

the option 'VARIABLE' doesn't work. Needs to be changed to '' (that is: empty). Putting 'VARIABLE' doesn't return a quote to the customer

Link to comment
Share on other sites

Maybe this has been resolved already but here is my solution for sorting the results in order of price (as requested in "what I could use help on" in install.txt).

 

all in modules/shipping/usps.php

 

After:	  $rates = array();
Add:	  $rates_sorter = array();

After:	  $rates[] = array($service => $postage);
Add:	  $rates_sorter[] = $postage;

Replace:	   return ((sizeof($rates) > 0) ? $rates : false);
With:   
  // Sort Rates
  asort($rates_sorter);
  print_r($rates_sorter);

  $sorted_rates = array();
  foreach (array_keys($rates_sorter) as $key) {
	$sorted_rates[] = $rates[$key];
  }


  return ((sizeof($sorted_rates) > 0) ? $sorted_rates : false);

 

hope others find it useful.

Link to comment
Share on other sites

Maybe this has been resolved already but here is my solution for sorting the results in order of price (as requested in "what I could use help on" in install.txt).

 

all in modules/shipping/usps.php

 

After:	  $rates = array();
Add:	  $rates_sorter = array();

After:	  $rates[] = array($service => $postage);
Add:	  $rates_sorter[] = $postage;

Replace:	   return ((sizeof($rates) > 0) ? $rates : false);
With:   
  // Sort Rates
  asort($rates_sorter);
  print_r($rates_sorter);

  $sorted_rates = array();
  foreach (array_keys($rates_sorter) as $key) {
	$sorted_rates[] = $rates[$key];
  }


  return ((sizeof($sorted_rates) > 0) ? $sorted_rates : false);

 

hope others find it useful.

 

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

Link to comment
Share on other sites

Nice.

 

One edit though:

REPLACE:
               return ((sizeof($rates) > 0) ? $rates : false);

WITH:
//Sort Rates
asort($rates_sorter);
print_r($rates_sorter);

$sorted_rates = array();
foreach (array_keys($rates_sorter) as $key){
	$sorted_rates[] = $rates[$key];
}

return ((sizeof($sorted_rates) > 0) ? $sorted_rates : false);

 

$sorted_rates[] = $rates[$keys]; should have been $sorted_rates[] = $rates[$key];

But it works! Thanks!

Edited by naps1saps
Link to comment
Share on other sites

Thank you Ben Bogart.

 

V4.1.3 has now been released with the cost sorting fix and a few more changes/adjustments.

 

Please be aware of the ounces not being rounded, so they are displayed with decimals like .33333333333... Please let me know if this becomes a problem. I'll fix it in a later update.

Link to comment
Share on other sites

Hi,

I installed the new update today and am having the following error show in the admin panel. Fatal error: Call to undefined function: tep_cfg_select_multioption() in /mnt/w0207/d18/s05/b02d72b0/www/catalog/catalog/admin/modules.php(212) : eval()'d code on line 1

I have changed the config table in the database to TEXT and relodaded the usps option.

Any ideas?

Link to comment
Share on other sites

I haven't installed the new Beta yet so maybe this is fixed in it, but right now when I choose First Class mail as an option to be displayed (in admin) it does not show up for the end user. I have selected first class, priority, and express, but only priority and express show up. Is this a bug?

 

Thanks,

-Mike

Link to comment
Share on other sites

I just updated to the new Beta and the First Class option still isnt showing and now on the top of the page (where the shipping options are displayed to the end user) I have this: Array ( [1] => 5.20 [0] => 16.50 )

 

Any ideas?

 

-Mike

Link to comment
Share on other sites

So I found out what was happening with the array text... On line 559 there is a call to print_r($rates_sorter); which will print out the rates. So just comment that out and it goes away. I still, however, have the issue of First Class option not showing. If anyone has some insight on how to get this working I would appreciate it.

 

Thanks,

-Mike

Link to comment
Share on other sites

Yeah, that's usually what happens when firstclass doesn't show up.

As far as the Array = ... at the top of the screen, that's my mystake. I forgot to take it out I guess. Sorry.

 

So to everyone who has it installed, remove the print_r($rates_sorter); from line 559.

Link to comment
Share on other sites

I added a rounding function to prevent .33333333333333333... weight displays and removed the print array code.

 

So go ahead and get V4.1.4 if you like. There aren't any new features or major additions, so it's up to you if you want to install it or not.

Link to comment
Share on other sites

I'm not sure if this is the exact same problem others are having, but for a number of the stores I've built they NEVER use Domestic First Class in a Letter container and thus were getting slightly too low prices returned for First Class Packages. If you're in the same boat, here's how I fixed it:

 

Change this bit of code:

 

//FIRST CLASS MAIL OPTIONS
	if ($key == 'First-Class Mail'){
		$this->FirstClassMailType = '<FirstClassMailType>LETTER</FirstClassMailType>';

 

to this:

 

//FIRST CLASS MAIL OPTIONS
	if ($key == 'First-Class Mail'){
		$this->FirstClassMailType = '<FirstClassMailType>PARCEL</FirstClassMailType>';

 

Basically, you just need to set "LETTER" to "PARCEL". I am using v4.1 FYI.

Link to comment
Share on other sites

I'm sorry if I am repeating a post. If I am could someone just let me know were to look?

 

My problem is when someone checks out using USPS shipping no mater what price they pick it reverts back to the "Express" shipping and price. I do not know if it is something that has changed or if it has always been that way, when I tested it I don't think I tested that. I don't get any error messages and everything looks good, logo and all, and the UPS shipping is fine. If you check out with "Express" every thing is fine.

 

Has anyone else had this problem?

 

Thanks,

Crystal

Link to comment
Share on other sites

I'm sorry if I am repeating a post. If I am could someone just let me know were to look?

 

My problem is when someone checks out using USPS shipping no mater what price they pick it reverts back to the "Express" shipping and price. I do not know if it is something that has changed or if it has always been that way, when I tested it I don't think I tested that. I don't get any error messages and everything looks good, logo and all, and the UPS shipping is fine. If you check out with "Express" every thing is fine.

 

Has anyone else had this problem?

 

Thanks,

Crystal

 

Are you using v4.1 or higher? If not, that might fix your problem.

Link to comment
Share on other sites

I did not. I looked at the new ones, do you suggest 4.0 alpha or 4.1, 4.1.2, or 4.1.3 bata?

 

personally, i'm using v4.1 but i've made some changes to get it 100%. from what the rest of the thread seems to say, v4.1.4 might be best.

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