wkdwich Posted November 14, 2013 Posted November 14, 2013 Didnt work for me either I did the same except I didnt REMOVE that whole second code chunk (preg replace), just replaced that one line. no quotes, no error message on the site either.. and this is the response report: Request:API=RateV4&XML=<RateV4Request USERID="220WWWEB5787"><Revision>2</Revision><Package ID="0"><Service>PRIORITY COMMERCIAL</Service><ZipOrigination>11779</ZipOrigination><ZipDestination>24151</ZipDestination><Pounds>0</Pounds><Ounces>16</Ounces><Container>VARIABLE</Container><Size>REGULAR</Size><Machinable>TRUE</Machinable></Package><Package ID="1"><Service>EXPRESS COMMERCIAL</Service><ZipOrigination>11779</ZipOrigination><ZipDestination>24151</ZipDestination><Pounds>0</Pounds><Ounces>16</Ounces><Container>VARIABLE</Container><Size>REGULAR</Size><Machinable>TRUE</Machinable></Package></RateV4Request> Response: I fooled with some different settings.. (turning off the Int'l rules option for instance) with no change Quote Debbie DFranklin County, VA "Moonshine Capitol of the World"osCmax Mobile Template oscmaxtemplates.com
clustersolutions Posted November 14, 2013 Posted November 14, 2013 The comment is correct that XML response is being returned in CHUNKED format. Here is a workaround that I've put in. Hopefully it helps you: I run USPS Methods 7.1 and am having no issues after making the following changes: First you will need to define a function for HTTP_CHUNKED_DECODE somewhere within the code: /** * dechunk an http 'transfer-encoding: chunked' message * * @[member='param'] string $chunk the encoded message * @[member='Return'] string the decoded message. If $chunk wasn't encoded properly it will be returned unmodified. */ function http_chunked_decode($chunk) { $pos = 0; $len = strlen($chunk); $dechunk = null; while(($pos < $len) && ($chunkLenHex = substr($chunk,$pos, ($newlineAt = strpos($chunk,"\n",$pos+1))-$pos))) { if (!$this->is_hex($chunkLenHex)) { trigger_error('Value is not properly chunk encoded', E_USER_WARNING); return $chunk; } $pos = $newlineAt + 1; $chunkLen = hexdec(rtrim($chunkLenHex,"\r\n")); $dechunk .= substr($chunk, $pos, $chunkLen); $pos = strpos($chunk, "\n", $pos + $chunkLen) + 1; } return $dechunk; } /** * determine if a string can represent a number in hexadecimal * * @[member='param'] string $hex * @[member='Return'] boolean true if the string is a hex, otherwise false */ function is_hex($hex) { // regex is for weenies $hex = strtolower(trim(ltrim($hex,"0"))); if (empty($hex)) { $hex = 0; }; $dec = hexdec($hex); return ($hex == dechex($dec)); } Find the occurrences of if ($http->Get('/shippingAPI.dll?' . $request)) $body = $http->getBody(); and change to if ($http->Get('/shippingAPI.dll?' . $request)) { $body = preg_replace( array( '{<sup>®</sup>}', /* Registered Trademark symbol - July 2013 update */ '{<sup>™</sup>}', /* Trademark symbol - July 2013 update */ '/<br>/' ), array ( '', '', '' ), htmlspecialchars_decode($this->http_chunked_decode($http->getBody()))); } All of my quotes come up for both domestic and international without issue. If someone can update this post with the correct locations within the module that would be great. This make sense and we konw who's the XML expert here and I knew someone would know a thing or two about these hex codes...will try this fix as soon as done fighting other fires!!! Thx! Quote
clustersolutions Posted November 14, 2013 Posted November 14, 2013 Report back...it worked!!! Thanks surfalot! Ur a hero! Quote
♥kymation Posted November 14, 2013 Posted November 14, 2013 I've posted an update on the USPS Methods Rates V4 Intl Rates V2 addon. This contains the code posted by @@badlhby on the USPS Methods support thread. I simply modified the module to work with that code. I have tested both the stock and MVS modules and they seem to work. Please let me know if you find a case where this does not work. Regards Jim wkdwich 1 Quote See my profile for a list of my addons and ways to get support.
wkdwich Posted November 14, 2013 Posted November 14, 2013 woooohooo that worked.. I see just a few itty bitty differences from what I was trying.. specifically.. if ($http->Get('/shippingapi.dll?' . $request)) { $response = http_chunked_decode( $http->getBody() ); the chuncked part of that I was totally missing.. thanks all!!!! Quote Debbie DFranklin County, VA "Moonshine Capitol of the World"osCmax Mobile Template oscmaxtemplates.com
wkdwich Posted November 14, 2013 Posted November 14, 2013 @@kymation thanks.. did I say thanks??? woohoo thanks :) :D Quote Debbie DFranklin County, VA "Moonshine Capitol of the World"osCmax Mobile Template oscmaxtemplates.com
Jayman11 Posted November 15, 2013 Posted November 15, 2013 Jim...you are the man! Thank you again, I am back and running with all my domestic and international services! I've posted an update on the USPS Methods Rates V4 Intl Rates V2 addon. This contains the code posted by @@badlhby on the USPS Methods support thread. I simply modified the module to work with that code. I have tested both the stock and MVS modules and they seem to work. Please let me know if you find a case where this does not work. Regards Jim Quote
♥kymation Posted November 15, 2013 Posted November 15, 2013 Not my code this time, I just cleaned it up a bit and put it up. I'm just glad somebody figured out what that encoding was. I thought it looked familiar and it was driving me crazy. Regards Jim Quote See my profile for a list of my addons and ways to get support.
wkdwich Posted November 15, 2013 Posted November 15, 2013 @@badlhby aww.. so sorry didnt mean to forget you! thank you for finding that and helping make it work! Quote Debbie DFranklin County, VA "Moonshine Capitol of the World"osCmax Mobile Template oscmaxtemplates.com
wkdwich Posted November 15, 2013 Posted November 15, 2013 hate to be the bearer.. but.. SOMETIMES I am getting a warning about cant chunk.. more on the international the domestic.. and now that I want to copy the error message it won;t come up.. grrrrr Quote Debbie DFranklin County, VA "Moonshine Capitol of the World"osCmax Mobile Template oscmaxtemplates.com
♥kymation Posted November 15, 2013 Posted November 15, 2013 Do you get the correct quotes when that happens? It's possible that USPS is sending some quotes that are not chunked. I think that happened sometimes on some of my tests, but I also can't prove anything. If you are getting quotes, just comment out the error message and forget about it. Regards Jim Quote See my profile for a list of my addons and ways to get support.
wkdwich Posted November 15, 2013 Posted November 15, 2013 Jim, I'm embarrassed to say I dont know.. I was so freaked out by it.. my thought process was cached so I just hit refresh I saw it twice in moving from US to AU shipping several times I'll check again and be sure to stop and examine next time Quote Debbie DFranklin County, VA "Moonshine Capitol of the World"osCmax Mobile Template oscmaxtemplates.com
wkdwich Posted November 15, 2013 Posted November 15, 2013 (edited) here ya go.. I just went back in and clicked checkout again (had left it on the catalog main page) Warning: Value is not properly chunk encoded in /home/[user]/public_html/catalog/includes/modules/shipping/usps.php on line 651 that was using an AU address for shipping..yes I got a quote and yes it looks proper: United States Postal Service >>Click here to view shipping regulations for your country<< First-Class Mail® International Large Envelope $15.40 Priority Mail International® $45.95 Priority Mail Express International™ $62.35 leaving that as is I changed to a US shipping address and now got the same warning, also did get very correct rate quotes.. it allows me to proceed and get to the payment screen and all looks fine there.. no warnings.. shipping is being added at this point properly Edited November 15, 2013 by wkdwich Quote Debbie DFranklin County, VA "Moonshine Capitol of the World"osCmax Mobile Template oscmaxtemplates.com
♥altoid Posted November 15, 2013 Posted November 15, 2013 After updating to the latest add on via Jim -> USPS Rate V4 Intl Rate V2_r3 domestic US shipping is working fine international shipping gives something like this: Warning: Value is not properly chunk encoded in /home/myusername/public_html/includes/modules/shipping/usps.php on line 649 Warning: Illegal string offset 'ServiceName' in /home/myusername/public_html/includes/modules/shipping/usps.php on line 111 With the second warning repeating numerous times. Quote I am not a professional webmaster or PHP coder by background or training but I will try to help as best I can. I remember what it was like when I first started with osC. It can be overwhelming. However, I strongly recommend considering hiring a professional for extensive site modifications, site cleaning, etc. There are several good pros here on osCommerce. Look around, you'll figure out who they are.
♥kymation Posted November 15, 2013 Posted November 15, 2013 @@altoid Same question: Are you getting quotes when you get the error message? If you are, comment out the error message. Regards Jim Quote See my profile for a list of my addons and ways to get support.
spiritalan Posted November 15, 2013 Posted November 15, 2013 @@altoid Same question: Are you getting quotes when you get the error message? If you are, comment out the error message. Regards Jim Where do you comment out the error message? Thanks Quote Production:osCommerce V. 2.3.4BSVPS Box
AllThingsTrendy Posted November 15, 2013 Posted November 15, 2013 I'm having the same issue as @@altoid but luckily I am only seeing the one warning (Warning: Value is not properly chunk encoded in /.../includes/modules/shipping/usps.php on line 649) for both domestic and international. It seems the quotes are coming back just fine now. MANY THANKS!!! to @@kymation and @@badlhby. However, I still can not figure out how to get rid of the warning: (Warning: Value is not properly chunk encoded in /.../includes/modules/shipping/usps.php on line 649) :x . I would have assumed the inclusion of the new function would have resolved this warning. Surely I am missing something??????? Quote Anthony David AllThingsTrendy.com
bburgess7 Posted November 15, 2013 Posted November 15, 2013 Last night USPS released an update to revert back to the original response format (no chunk encoding) temporarily to fix the issue for users until a more permanent solution can be reached. Does going back to the no-chunk format break anyone who has implemented this patch? Quote
Chadduck Posted November 15, 2013 Posted November 15, 2013 Not certain if everyone has realized it or not - USPS has "fixed" their garbage transmission. I was working on updating and installing when a customer called about his order.... I looked at his order and discovered that he had gotten a CORRECT response... further investigation showed it is now working without any changes on my part. Quote
spiritalan Posted November 15, 2013 Posted November 15, 2013 (edited) Not certain if everyone has realized it or not - USPS has "fixed" their garbage transmission. I was working on updating and installing when a customer called about his order.... I looked at his order and discovered that he had gotten a CORRECT response... further investigation showed it is now working without any changes on my part. Which USPS module are you using USPS Methods or USPS Rate V4, Intl Rate V2. These are not the same modules. The thread you are posting in is USPS Rate V4, Intl Rate V2. Edited November 15, 2013 by spiritalan Quote Production:osCommerce V. 2.3.4BSVPS Box
♥kymation Posted November 15, 2013 Posted November 15, 2013 You can comment out this line to get rid of the error message: trigger_error('Value is not properly chunk encoded', E_USER_WARNING); I would like to warn everyone that you should have error reporting turned off in any live store. No customer should ever see a PHP or MySQL error message. Regards Jim videod 1 Quote See my profile for a list of my addons and ways to get support.
videod Posted November 16, 2013 Posted November 16, 2013 (edited) Where do you comment out the error message? Thanks I commented the following line out as follows: BEFORE- trigger_error('Value is not properly chunk encoded', E_USER_WARNING); AFTER- //trigger_error('Value is not properly chunk encoded', E_USER_WARNING); My file is located at /home/includes/modules/shipping/usps.php, and was the only file I modified from the latest upload from Kymation (USPS Methods Rates V4 Intl Rates V2 11/2013 Update). I don't believe that USPS backed out of their HUGE mistake as was stated by someone today. Since my fix was really simple.. once it was identified. I backed out of the fix from all of you, and I was not able to obtain any pricing from USPS (OSC v2.3.3). So I am sticking with this fix posted by Kymation on the official site... and mod it with the error line commented out. Thanks everyone!!!! Edited November 16, 2013 by videod Quote
soundzgood2 Posted November 16, 2013 Posted November 16, 2013 Last night USPS released an update to revert back to the original response format (no chunk encoding) temporarily to fix the issue for users until a more permanent solution can be reached. Does going back to the no-chunk format break anyone who has implemented this patch? Hi Ben - what proof do you have they've done this? If I restore the original code the module breaks, so not sure they've done this. Simon Quote About me
wkdwich Posted November 16, 2013 Posted November 16, 2013 @@videod In theory I agree and hadn't jumped in the jumping backwards hoop @@kymation thanks for pointing out the line to be commented out.. done.. I have quotes and no errors.. now to head off to fix my clients as I think we have a real solution now - permanent?? probably not.. but its put us all back in business,, thanks everyone! Quote Debbie DFranklin County, VA "Moonshine Capitol of the World"osCmax Mobile Template oscmaxtemplates.com
wkdwich Posted November 16, 2013 Posted November 16, 2013 Oh.. thinking.. it might be helpful to have that error message at some point.. can you do a quick have it write to an error log but leave it commented out for the time being??? Quote Debbie DFranklin County, VA "Moonshine Capitol of the World"osCmax Mobile Template oscmaxtemplates.com
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.