News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

USPS V5 - ZIP+4 Error with fix

Started by piperpilot, May 02, 2011, 22:55:14 PM

Previous topic - Next topic

piperpilot

I was experiencing a large amount of my customers entering ZIP+4 addresses which returns a very cryptic message about not being able to ship via USPS.  I understand from Reggie that this is because USPS doesn't support ZIP+4 in their zip code handling in the API.

I thought about limiting the entry field for the address, but this would screw up international addresses and postal codes.  So here is the better fix.  Hopefully Reggie will pick this up and put it as part of the standard files...

In uspsv5.php (new version), around line 340...

Look for:

if($dest_zip==''){
uspsv5::debugLog("uspsv5::get_rates_array() - invalid destination country.");
return null;
}


After that insert the following code snippet:


// Check to make sure the user didn't enter a ZIP+4 Zip Code, its not supported
if((strlen($dest_zip) > 5) && ($this->domestic===true)) {
$dest_zip = substr($dest_zip, 0, 5);
}


This makes a domestic zip code only 5 digits long.

Hope it helps someone else.

PiperPilot

snelson

I made this code correction and it worked perfectly.
Thanks