9 diget zip codes

Are they ever going to fix the issue with 9 digit zip codes? Does anyone know a fix? Does anyone know where to find the template for that section of the page that asks for zip so I can at least put a note for customers NOT to enter 9 digit?



It always astounds me the stupid things CS-cart has problems with… Add this one to the list of needing a sales report for taxes each month!!!


<br />
Message<br />
Subject:  	no shipping options?<br />
Body:  	I'm trying to check out and get:<br />
<br />
"Unfortunately no shipping options are available for your location.<br />
Please contact us and we will see about delivering to you."<br />
<br />
This is for the address:<br />
<br />
David Hidden1<br />
Akamai Technologies<br />
Hidden Ctr<br />
Cambridge MA 01242-1401<br />
<br />
Something seems to have confused the system. USPS delivers to this address just fine. I can't complete my purchase, though.<br />
<br />
Thank you for using our shopping cart. <br />

```<br />
<br />
James<br />
[url]http://www.RPGShop.com[/url]

2.0.12 allows Zip+4 format.



Bob

[quote name=‘jobosales’]2.0.12 allows Zip+4 format.



Bob[/QUOTE]



I’m using 2.0.12 … I just tested with my own account and added 53150-8170 and it fails…



Unfortunately no shipping options are available for your location.
Please contact us and we will see about delivering to you.




So attempt to remove the “-” as that sounds like something the programmers could have overlooked not being from the USA… But I get this:



The ZIP / Postal code in the Zip/postal code field is incorrect. The correct format is 01342 (01342-5678).




So tell me how that is WORKING? I’m definatly on 2.0.12 as I just checked the upgrade center tab.



James

http://www.RPGShop.com

[quote name=‘gamegoblin’]I’m using 2.0.12 … I just tested with my own account and added 53150-8170 and it fails…



Unfortunately no shipping options are available for your location.
Please contact us and we will see about delivering to you.




So attempt to remove the “-” as that sounds like something the programmers could have overlooked not being from the USA… But I get this:



The ZIP / Postal code in the Zip/postal code field is incorrect. The correct format is 01342 (01342-5678).




So tell me how that is WORKING? I’m definatly on 2.0.12 as I just checked the upgrade center tab.

[/QUOTE]



Just reporting my results:

[url]http://idisk.mac.com/jobosales/Public/checkout-zip9.png[/url]



I can place the order without any problem.



Bob

[quote name=‘jobosales’]Just reporting my results:

[url]http://idisk.mac.com/jobosales/Public/checkout-zip9.png[/url]



I can place the order without any problem.



Bob[/QUOTE]



Great, can you do me a big favor and try my system? Maybe it’s a setup/configure or old code snuck by kind of problem?



Right back at you…



[url]http://www.rpgshop.com/RPGShop_Checkout_Z9.jpg[/url]



James

Yep, I can confirm your problem.



I’ve tried on both a fresh install of 2.0.12 and on an upgraded install to 2.0.12 - both work.



I am trying to remember where I saw the zip validation code. I’ll take a look around the code.



Bob

Take a look at /skins/YOURSKIN/customer/views/profiles/components/profiles_scripts.tpl. This is what I have:

{literal}
var zip_validators = {
US: {
regex: /^(\d{5})(-\d{4})?$/,
format: '01342 (01342-5678)'
},
CA: {
regex: /^(\w{3} \w{3})$/,
format: 'K1A OB1'
}
}
{/literal}




Bob

[quote name=‘jobosales’]Take a look at /skins/YOURSKIN/customer/views/profiles/components/profiles_scripts.tpl. This is what I have:

Bob[/QUOTE]



The same block of code is in my skin dir “aquarelle_red” as well. A bit more code after it too but I assume you just quoted the relevent part.



So, weird. Is there any setup options for the USPS that I may be missing?



James

Yeah, quoted just the relevant part.



I think we have zeroed in on the difference: I am using UPS and you are using USPS. I just found the following:

[url]http://forum.cs-cart.com/showthread.php?t=11339[/url]



Seems like the postal service calculator does not like +4 addressing.



Bob

[quote name=‘jobosales’]Yeah, quoted just the relevant part.



Seems like the postal service calculator does not like +4 addressing.



Bob[/QUOTE]



Sounds like our F@&#$* goverment. So, back to the orignal then, where do I find the template for the profile screen to warn them not to use +4 ? I searched for “postal” in my templates directories and came up empty.



James

You can change the validation routine above /skins/YOURSKIN/customer/views/profiles/components/profiles_scripts.tpl:



From:

var zip_validators = {
US: {
regex: /^(\d{5})(-\d{4})?$/,
format: '01342 (01342-5678)'
},




To:

var zip_validators = {
US: {
regex: /^(\d{5})?$/,
format: '01342'
},




They will still be able to enter a +4 zip in the shipping estimator but this will catch the profile fields. I’ll try to hunt down the routine for the estimator later.



Bob

[QUOTE]Seems like the postal service calculator does not like +4 addressing[/QUOTE]



CS-Cart should be stripping the last 4 digits from the zip code before requesting the rates from US Postal Service. They are already stripping the last 4 digits to obtain rates from UPS & Fedex, right?



If so, then they should be stripping the digits for the rate calls to US Postal as well !!

Thanks Bob!



(Sorry, I must have been typing at the same time as your reply) :wink:



Yeah, I just simulated a test order & sure enough, as soon as I entered a valid postal adress with an extended 9 digit zip code, US Postal rates stopped being returned. Fedex rates were returned as we use both services.



Removed the last 4 digits from the zip & the US Postal rates were returned again.



I could have sworn that CS-Cart had this situation fixed awhile back, maybe I am imagining…



Regardless, this is a bug which CS-Cart should have discovered & fixed by now!:rolleyes:

[quote name=‘Struck’]CS-Cart should be stripping the last 4 digits from the zip code before requesting the rates from US Postal Service. They are already stripping the last 4 digits to obtain rates from UPS & Fedex, right?



If so, then they should be stripping the digits for the rate calls to US Postal as well !![/QUOTE]

UPS requests will pass the full Zip+4 code to the UPS calculator. You can see this by turning on logging of Requests where you can then examine what data was passed to and from your shipper. I don’t know whether or not FedEx works with Zip+4 addressing but you will be able to determine this by checking the logs.



However, it clearly seems like a bug to me if CS-Cart passes the full 9-digit zip to USPS knowing that they do not accept it:

[QUOTE]In the documentation which we used for integration USPS shipping method in CS-Cart it is said that it only accepts 5-digit ZIP codes in the XML requests. If ZIP+4 is sent, the error will occur.



Unfortunately, we can do nothing to change USPS behavior, but we can offer you to pass only first five digits to USPS if zip code is entered in the zip+4 format. Please let us know whether this suits you.

[/QUOTE]



No, they can do nothing to change USPS behavior but they can submit the XML to meet the USPS requirements. They should fix this by stripping the “+4” part of the zip code prior to sending the request AS A BUG FIX. I sometimes wonder what delusional world the developers live in.



As I said above, you can modify the validation routine for profiles to not allow the “+4” addressing. Make sure you clear your template cache.



It does not appear that any validation is done in the shipping estimator.



Bob

[QUOTE]However, it clearly seems like a bug to me if CS-Cart passes the full 9-digit zip to USPS knowing that they do not accept it[/QUOTE]



Thanks for helping to clarify this Bob!

I will enter this as a bug.



And Yeah, I Really hope the the CS developers will put more thought / effort into the shipping functionality of CS-Cart, it REALLY needs some attention!

Support got back to me with a fix and I installed/tested it and it works so here it is:



In order to fix it you should replace the following part of code:



$origination_postal = $origination[‘zipcode’];

$destination_postal = $location[‘zipcode’];





with this one:



// The zip code should be in 5 digit format so we cut all digits after “-”

$origination_postal = preg_replace(‘/-\d*/i’, ‘’, trim($origination[‘zipcode’]));

$destination_postal = preg_replace(‘/-\d*/i’, ‘’, trim($location[‘zipcode’]));





in the “usps.php” file located in the “shippings” directory of your CS-Cart installation.



James

http://www.RPGShop.com