Post by sparkybarkalot » Fri Jan 08, 2010 1:52 am

I cannot get the USPS shipping choice to appear.

I have applied Qphoric's patch which solved the same error that jerad had in his initial post, but after applying the patch I now have the same error that jerad had in his second post. My error is:

2010-01-07 12:33:58 - PHP Notice: Undefined index: value in /PATH_TO_STORE/catalog/model/shipping/usps.php(348) : eval()'d code on line 1

(I've shortened the actual store path here in this forum post to 'PATH_TO_STORE')

If I enable USPS and Qphoric's FedEx XML extensions, no shipping options appear and I get the error above. If I disable USPS and enable Qphoric's FedEx XML extension, the FedEx choice appears and works great. If I enable USPS and disable Qphoric's FedEx, once again no shipping options appear.

This is on a server I manage myself and I will be surprised if it's a server configuration issue, as it's well maintained, up-to-date and I've got about 100 domains on it. Any ideas?


Posts

Joined
Thu Dec 24, 2009 12:03 am

Post by sparkybarkalot » Fri Jan 08, 2010 11:47 am

Follow up to my last post:

I added the @ sign before this line in Qphoric's patched code on line 346:

Code: Select all

$php_stmt .= '[$xml_elem[\'tag\']] = $xml_elem[\'value\'];';
so it now looks like this:

Code: Select all

@$php_stmt .= '[$xml_elem[\'tag\']] = $xml_elem[\'value\'];';
Still getting that error I was having showing in the error logs of course, but now the USPS shipping option appears as expected and seems to be working correctly at first glance.

I'm not exactly handy with PHP, so don't know if this is a bad fix. Any thoughts?


Posts

Joined
Thu Dec 24, 2009 12:03 am

Post by Johnathan » Sat Jan 23, 2010 7:08 am

This error occurs for me in 1.4.0 as well. Adding the @ symbol before

Code: Select all

$php_stmt .= '[$xml_elem[\'tag\']] = $xml_elem[\'value\'];';
does not suppress the error. Also, I can get rates when using Guest Checkout, but not when checking out with a customer account. Anyone know of a fix?

Edit: After further testing, the error occurs when the total weight limit is over 4 pounds. I assume this is because of a 4 pound weight limit on something (e.g. international priority flat-rate envelopes). This occurs even when no international methods of shipping are checked.

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by Johnathan » Sat Jan 23, 2010 12:30 pm

I think I figured out why this error is occurring. It's related to the issue described here:

http://forum.opencart.com/viewtopic.php?f=31&t=8427

Since the USPS module was interpreting ounces as pounds, anything over "4 pounds" was actually being interpreted as 16 times its value. So "5 pounds" was 5*16 = 80 pounds, which is over the 70 pound weight limit for USPS.

The change suggested by Qphoria in that thread has fixed the problem for me.

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by icockrum » Wed Feb 03, 2010 2:58 pm

Hiya - I see the [RESOLVED] tag in the subject head, but I still have issues with USPS. Working with 1.4.0, I worked through each of these issues and edits in this thread until I found Qphoria's edited v1.3.4 file. That got me most of the way...

With Geo Zone set to the default 'All Zones' in the USPS admin, the checkout now shows International USPS shipping rates. It does not show domestic rates. Instead, I receive these errors:

Warning: Missing argument 2 for ModelShippingUsps::getQuote(), called in /.../guest_step_2.php on line 42 and defined in /.../usps.php on line 3
Notice: Undefined variable: zone_id in /.../usps.php on line 7

I tried creating a 'United States' zone and selecting that in the USPS admin, but that results in no shipping options at all in the checkout.

Is this a bug, or have I failed in some way to set my Zones or Geo Zones correctly? The documentation is not entirely clear about the dependencies of zones and shipping.

If it's a bug, is it expected to be fixed in 1.4.1? Or should I invest in Qphoria's USPS mod?

Ivan
(New guy evaluating OpenCart)

Newbie

Posts

Joined
Sun Jan 31, 2010 3:35 pm

Post by Qphoria » Wed Feb 03, 2010 8:59 pm

icockrum wrote: Warning: Missing argument 2 for ModelShippingUsps::getQuote(), called in /.../guest_step_2.php on line 42 and defined in /.../usps.php on line 3
Notice: Undefined variable: zone_id in /.../usps.php on line 7
You can't use this patch with 1.4.0.
I will see about updating it for 1.4.0

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by icockrum » Thu Feb 04, 2010 1:48 am

Thank you! I figured that there might be some risk of incompatibility with 1.4.0, but frankly, I got further with the 1.3.4 patch than without.

For the most part, I am very much impressed with OpenCart and its community, and would like to install it for a client, but without USPS support I got nuthin'.

Ivan
(New guy evaluating OpenCart)

Newbie

Posts

Joined
Sun Jan 31, 2010 3:35 pm

Post by Qphoria » Thu Feb 04, 2010 5:00 am

Well there is always the Commercial version of USPS. That works fine with 1.4.0

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by icockrum » Thu Feb 04, 2010 5:08 am

That's fine, and I'm not opposed to paying you for the added functionality if it comes to that. I do think that the basic feature set should at least be made functional as advertised, so it can be evaluated on its own merits before adopting add-ons. I am eager to see what the 1.4.1 update brings.

Ivan

Newbie

Posts

Joined
Sun Jan 31, 2010 3:35 pm

Post by Qphoria » Fri Feb 05, 2010 1:13 am

Ok i've updated the patch to support 1.4.0
Get it from the original patch post on the first page

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by icockrum » Fri Feb 05, 2010 3:57 am

Thank you for jumping on that so quickly.

Unfortunately, I'm still getting this error:

Notice: Undefined index: value in /.../usps.php(386) : eval()'d code on line 1

I see this error in both Daniel's version and your edit. I take the error to mean that the problem lies in this subroutine:

Code: Select all

$data = array();  
$level = array();  

foreach ($value as $xml_elem) {  
	if ($xml_elem['type'] == 'open') {  
		if (array_key_exists('attributes', $xml_elem)) {  
			foreach (array_values($xml_elem['attributes']) as $attribute) {
				$level[$xml_elem['level']] = $attribute;
			}
		} else {  
			$level[$xml_elem['level']] = $xml_elem['tag'];  
		}  
	} 
	
	if ($xml_elem['type'] == 'complete') {  
		$start_level = 1;  
		$php_stmt = '$data';  
		
		while ($start_level < $xml_elem['level']) {  
			$php_stmt .= '[$level[' . $start_level . ']]';  
			
			$start_level++;  
		}
		
		$php_stmt .= '[$xml_elem[\'tag\']] = $xml_elem[\'value\'];';  
		
		eval($php_stmt);  
	}  
}  
As near as I can tell from reading about the 'Undefined index' notice, there's an undeclared variable being called from the evaluated statement, so I guess the problem lies somewhere in the concatenation of php_stmt.

Anyhow, I appreciate the time you've taken to help me, esp. since you're basically competing with your own commercial offering. I'll probably keep tinkering a bit, but I guess at some point I'll either wait and see what 1.4.1 offers or buy your plug-in.

Ivan

Newbie

Posts

Joined
Sun Jan 31, 2010 3:35 pm

Post by Qphoria » Fri Feb 05, 2010 5:11 am

Try adding @ in front of $php_stmt on that line

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by icockrum » Fri Feb 05, 2010 2:22 pm

I saw the earlier post about adding the @ symbol. I read up on that, and it seems that all it does is suppress PHP Notices? Just a symptomatic fix, no?

I finally sussed this out, though it took a bunch of hacking. The 'Undefined index' Notice stemmed from the routine I posted above, so I echo'd all that routine's variables until I found something that made sense (I've never used PHP, so I haven't got a proper debugger yet). The routine parses a series of delimited strings that are provided by USPS. It turned out that USPS was returning an error notification half way through the series, which actually broke the routine, because it has no error checking. The USPS error had to do with incorrect dimensions (but I forgot to document the exact message, grrr).

It appeared that the error was due to my settings in Extensions->Shipping->USPS. I had set Size: Large, Machinable: No, and entered values for Dimensions and Girth (I assumed that those fields provided default values). I reset Size:Normal and Machinable:Yes, cleared out my Dimensions and Girth.

And that fixed my problem. I can now see my USPS shipping options.

Unfortunately, now I can't duplicate the problem. After I got it working, I set USPS back to the 'bad' values, and it still works. All I can guess now is that maybe I entered an illegal character in one of the fields?

Ivan

Attachments

Picture 4.png

Picture 4.png (17.39 KiB) Viewed 8162 times


Newbie

Posts

Joined
Sun Jan 31, 2010 3:35 pm

Post by nocko » Mon Feb 08, 2010 6:10 am

Hello,

I have applied the USPS patch from Qphoria (thx!) and have called in to move the USPS acct to the production server.

Before I did this, I would get Shipping info required (?) and authorization failure. Now, I am getting encoding errors in Firefox. Chrome says "Webpage not available" gives this error:
Error 330 (net::ERR_CONTENT_DECODING_FAILED): Unknown error.
I checked the error log and am getting this:
- PHP Notice: Undefined index: value in /........./public_html/shop/catalog/model/shipping/usps.php(386) : eval()'d code on line 1
I tried:

Setting>local and tried both pounds and ounces
extensions >module >usps> dimensions/Machinable and even set my own geo zone (none work)
placing @ in front of $php_stmt in module/shipping/usps.php

When I uninstalled usps and enabled free shipping it went along nicely. Please help me with setting up USPS on my site. Is there anything I'm missing? I can provide more info if needed.

New member

Posts

Joined
Tue Jan 26, 2010 2:14 pm

Post by Qphoria » Mon Feb 08, 2010 11:37 pm

The first error is due to an issue with some pages showing php errors while compression is enabled. This seems to be an OpenCart issue starting with 1.3.4. To get around it, edit your settings area and under the "Server" tab set the compression to 0

That will then show you the second error, which is something with the xml parsing. The patch I made doesn't touch that code and you would likely get that error without the patch. I'm not the strongest xml guy so I'm not fully sure where the problem is with that.

I will see if I can look into it.

Q

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by icockrum » Tue Feb 09, 2010 1:32 am

Hi Nocko,

I had the same two errors with USPS.

Error 1: Qphoria knows his stuff, and his instruction to disable PHP compression worked for me.

Error 2: I found that the 'Undefined index' error occurs when USPS returns an error message in the XML stream. OpenCart's USPS module hasn't yet got any error checking in its xml handling, so it has no way to display the real USPS error message. If you feel like poking around the code, you can at least find out what that is.

In file:
catalog/model/shipping/usps.php

Find line:
$php_stmt .= '[$xml_elem[\'tag\']] = $xml_elem[\'value\'];';

After it, add this line:
echo('<br />$xml_elem[\'value\'] = ' . $xml_elem['value'] . '<br />');

That will print all the data from the USPS xml stream straight to the screen when you go to checkout, one var per line. When I tried this, the USPS error was the last line printed. (Sorry, I know that's an inelegant debug method, but I just started out with this stuff.) This won't solve your problem, but it should provide you enough information to figure out why USPS is choking.

Ivan

Newbie

Posts

Joined
Sun Jan 31, 2010 3:35 pm

Post by Qphoria » Tue Feb 09, 2010 1:35 am

I did add error message handling with the usps patch (which is why you see the "Authorization Failure" message.) Maybe there is more for parse error handling that I didn't catch.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by icockrum » Tue Feb 09, 2010 2:04 am

The error I found actually lies in the loop that converts the delimited USPS data into an array. I'm still not entirely clear on this, but here's how I see it...

- The routine is looking for tag/value pairs.
- In the case of an error message from USPS, there's only a single value.
- There's no pair, so one variable goes undefined.
- The routine tries to use the undefined value, resulting in the 'Undefined index' notice.

I figure it needs a line that checks for non-standard data, and, if found, logs and/or displays it.

Ivan

Newbie

Posts

Joined
Sun Jan 31, 2010 3:35 pm

Post by nocko » Wed Feb 10, 2010 3:51 am

Qphoria, that worked great! After setting compression to 0, the page loaded and showed that the error was a missing zip code field ;D I will have to make this field required.

icockrum, Thanks for the debug line! Turned out that I didn't need it.

You guys rock! Thanks!!! O0

New member

Posts

Joined
Tue Jan 26, 2010 2:14 pm

Post by Hartford » Sat May 29, 2010 4:14 am

Hi...

I'm trying to use the fix for the USPS module given in this thread, named: v134+v140_USPS_Fix.zip

I've downloaded this file several times, but when I try to uncompress it, I am getting "file corrupt" errors, and it will not unzip. I've tried several different downloads, and a couple of different unzip programs.

We are using OpenCart v1.3.4.

I'm seeing several posts on the subject of the USPS module, and perhaps I'm missing something. But it appears this is the file I need, if I can get it to work.

Your help is appreciated! Thanks.

Hartford

Newbie

Posts

Joined
Tue Dec 01, 2009 2:38 pm
Who is online

Users browsing this forum: No registered users and 5 guests