[Skip to main content](#vessel-content)

#   US 9 Digit Postal Code: USPS Shipping Module

##

- **[ELHS](/forum/user/5412-elhs "View ELHS's Profile")**
- [![ELHS's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar5412.jpg)](/forum/user/5412-elhs "View ELHS's Profile") Topic Author
- [ Offline](/forum/user/5412-elhs)

Less More

- Posts: 45
- Thank you received: 1
-
-

14 years 8 months ago [\#40901](#40901) by [ELHS](/forum/user/5412-elhs "View ELHS's Profile")  *[US 9 Digit Postal Code: USPS Shipping Module](/forum/3-bug-report/40901-us-9-digit-postal-code-usps-shipping-module#40901 "I have a small problem with the USPS shipping module? I noticed that the hyphen (-) in the US nine digit postal code causes the shipping module not to recognize it. For example postal code  19438-1059 causes a &quot;no shipping method available error&quot;  However if you enter the postal code without the hyphen like this 19438 1094 it works. Most people will enter the 9 digit postal code with the hyphen so I think the USPS Shipping Modules needs to be able to handle the presence of it.  Thank you,  Paul")* was created by *[ELHS](/forum/user/5412-elhs "View ELHS's Profile")*

I have a small problem with the USPS shipping module? I noticed that the hyphen (-) in the US nine digit postal code causes the shipping module not to recognize it. For example postal code

19438-1059 causes a "no shipping method available error"

However if you enter the postal code without the hyphen like this 19438 1094 it works. Most people will enter the 9 digit postal code with the hyphen so I think the USPS Shipping Modules needs to be able to handle the presence of it.

Thank you,

Paul

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC80MDkwMS11cy05LWRpZ2l0LXBvc3RhbC1jb2RlLXVzcHMtc2hpcHBpbmctbW9kdWxlP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86322
- Thank you received: 14281
-
-

14 years 8 months ago -  14 years 8 months ago [\#41049](#41049) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: US 9 Digit Postal Code: USPS Shipping Module](/forum/3-bug-report/40901-us-9-digit-postal-code-usps-shipping-module#41049 "I have a small problem with the USPS shipping module? I noticed that the hyphen (-) in the US nine digit postal code causes the shipping module not to recognize it. For example postal code  19438-1059 causes a &quot;no shipping method available error&quot;  However if you enter the postal code without the hyphen like this 19438 1094 it works. Most people will enter the 9 digit postal code with the hyphen so I think the USPS Shipping Modules needs to be able to handle the presence of it.  Thank you,  Paul")*

Hi,

Please replace the code:
$parcel-&gt;Pickup_Postcode = substr(trim(@$rate-&gt;shipping_params-&gt;post_code),0,6);
$parcel-&gt;Destination_Postcode = substr(trim($order-&gt;shipping_address-&gt;address_post_code),0,6);

by:
$parcel-&gt;Pickup_Postcode = substr(preg_replace('#[^a-z0-9]#i','',@$rate-&gt;shipping_params-&gt;post_code),0,6);
$parcel-&gt;Destination_Postcode = substr(preg_replace('#[^a-z0-9]#i','',$order-&gt;shipping_address-&gt;address_post_code),0,6);

in the file plugins/hikashopshipping/usps.php and that should do it.

Last edit: 14 years 8 months ago by [nicolas](/forum/user/63-nicolas "View nicolas's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC80MDkwMS11cy05LWRpZ2l0LXBvc3RhbC1jb2RlLXVzcHMtc2hpcHBpbmctbW9kdWxlP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[ELHS](/forum/user/5412-elhs "View ELHS's Profile")**
- [![ELHS's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar5412.jpg)](/forum/user/5412-elhs "View ELHS's Profile") Topic Author
- [ Offline](/forum/user/5412-elhs)

Less More

- Posts: 45
- Thank you received: 1
-
-

14 years 8 months ago -  14 years 8 months ago [\#41064](#41064) by [ELHS](/forum/user/5412-elhs "View ELHS's Profile")  Replied by *[ELHS](/forum/user/5412-elhs "View ELHS's Profile")* on topic *[Re: US 9 Digit Postal Code: USPS Shipping Module](/forum/3-bug-report/40901-us-9-digit-postal-code-usps-shipping-module#41064 "I have a small problem with the USPS shipping module? I noticed that the hyphen (-) in the US nine digit postal code causes the shipping module not to recognize it. For example postal code  19438-1059 causes a &quot;no shipping method available error&quot;  However if you enter the postal code without the hyphen like this 19438 1094 it works. Most people will enter the 9 digit postal code with the hyphen so I think the USPS Shipping Modules needs to be able to handle the presence of it.  Thank you,  Paul")*

Nicolas,

I just made the change now I get a fatal error. Specifically:

Fatal error: Call to undefined function preg_replace_() in /html/erielack/test-dev/joomla/plugins/hikashopshipping/usps/usps.php on line 113

Here is the screen shot of the code. I commented out the original and cut/pasted you code as directed.

I am running PHP 5.3.9

[ ![usps&#95;pcode.jpg](/forum/attachment/2923) ](/forum/attachment/2923 "usps&#95;pcode.jpg")

- [ ![usps&#95;pcode.jpg](/forum/attachment/2923) ](/forum/attachment/2923 "usps&#95;pcode.jpg") [ ](/forum/attachment/2923?download=1 "usps&#95;pcode.jpg")

Last edit: 14 years 8 months ago by [ELHS](/forum/user/5412-elhs "View ELHS's Profile"). Reason: Forgot PHP version

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC80MDkwMS11cy05LWRpZ2l0LXBvc3RhbC1jb2RlLXVzcHMtc2hpcHBpbmctbW9kdWxlP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86322
- Thank you received: 14281
-
-

14 years 8 months ago [\#41065](#41065) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: US 9 Digit Postal Code: USPS Shipping Module](/forum/3-bug-report/40901-us-9-digit-postal-code-usps-shipping-module#41065 "I have a small problem with the USPS shipping module? I noticed that the hyphen (-) in the US nine digit postal code causes the shipping module not to recognize it. For example postal code  19438-1059 causes a &quot;no shipping method available error&quot;  However if you enter the postal code without the hyphen like this 19438 1094 it works. Most people will enter the 9 digit postal code with the hyphen so I think the USPS Shipping Modules needs to be able to handle the presence of it.  Thank you,  Paul")*

Sorry it's a typo.

it should be preg_replace and not preg_replace_
I've corrected the code in my previous post.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC80MDkwMS11cy05LWRpZ2l0LXBvc3RhbC1jb2RlLXVzcHMtc2hpcHBpbmctbW9kdWxlP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[ELHS](/forum/user/5412-elhs "View ELHS's Profile")**
- [![ELHS's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar5412.jpg)](/forum/user/5412-elhs "View ELHS's Profile") Topic Author
- [ Offline](/forum/user/5412-elhs)

Less More

- Posts: 45
- Thank you received: 1
-
-

14 years 8 months ago [\#41067](#41067) by [ELHS](/forum/user/5412-elhs "View ELHS's Profile")  Replied by *[ELHS](/forum/user/5412-elhs "View ELHS's Profile")* on topic *[Re: US 9 Digit Postal Code: USPS Shipping Module](/forum/3-bug-report/40901-us-9-digit-postal-code-usps-shipping-module#41067 "I have a small problem with the USPS shipping module? I noticed that the hyphen (-) in the US nine digit postal code causes the shipping module not to recognize it. For example postal code  19438-1059 causes a &quot;no shipping method available error&quot;  However if you enter the postal code without the hyphen like this 19438 1094 it works. Most people will enter the 9 digit postal code with the hyphen so I think the USPS Shipping Modules needs to be able to handle the presence of it.  Thank you,  Paul")*

Ok, I fixed the typ0 and now the plugin doesn't recognize the postal code with or without the hyphen. It is getting late here and its really early in the morning for you. This can wait until tomorrow as I am not in production nor do I have a strict deadline to meet.

Thank you,

Paul

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC80MDkwMS11cy05LWRpZ2l0LXBvc3RhbC1jb2RlLXVzcHMtc2hpcHBpbmctbW9kdWxlP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86322
- Thank you received: 14281
-
-

14 years 8 months ago [\#41195](#41195) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: US 9 Digit Postal Code: USPS Shipping Module](/forum/3-bug-report/40901-us-9-digit-postal-code-usps-shipping-module#41195 "I have a small problem with the USPS shipping module? I noticed that the hyphen (-) in the US nine digit postal code causes the shipping module not to recognize it. For example postal code  19438-1059 causes a &quot;no shipping method available error&quot;  However if you enter the postal code without the hyphen like this 19438 1094 it works. Most people will enter the 9 digit postal code with the hyphen so I think the USPS Shipping Modules needs to be able to handle the presence of it.  Thank you,  Paul")*

Make sure that you replace both preg_replace_ in the code and not only the first one.
I don't see why that code would not work.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC80MDkwMS11cy05LWRpZ2l0LXBvc3RhbC1jb2RlLXVzcHMtc2hpcHBpbmctbW9kdWxlP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[ELHS](/forum/user/5412-elhs "View ELHS's Profile")**
- [![ELHS's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar5412.jpg)](/forum/user/5412-elhs "View ELHS's Profile") Topic Author
- [ Offline](/forum/user/5412-elhs)

Less More

- Posts: 45
- Thank you received: 1
-
-

14 years 8 months ago [\#41251](#41251) by [ELHS](/forum/user/5412-elhs "View ELHS's Profile")  Replied by *[ELHS](/forum/user/5412-elhs "View ELHS's Profile")* on topic *[Re: US 9 Digit Postal Code: USPS Shipping Module](/forum/3-bug-report/40901-us-9-digit-postal-code-usps-shipping-module#41251 "I have a small problem with the USPS shipping module? I noticed that the hyphen (-) in the US nine digit postal code causes the shipping module not to recognize it. For example postal code  19438-1059 causes a &quot;no shipping method available error&quot;  However if you enter the postal code without the hyphen like this 19438 1094 it works. Most people will enter the 9 digit postal code with the hyphen so I think the USPS Shipping Modules needs to be able to handle the presence of it.  Thank you,  Paul")*

Nicolas,

Here is the code:
Code:

$query = 'SELECT currency_id FROM '.hikashop_table('currency').' WHERE currency_code=\'USD\''; $db =&amp; JFactory::getDBO(); $db-&gt;setQuery($query); $currency = $db-&gt;loadResult(); $parcel = null; $parcel-&gt;Country = $order-&gt;shipping_address_full-&gt;shipping_address-&gt;address_country-&gt;zone_code_2; /* Per Nicolas at Hikara Software 02/25/2012 * $parcel-&gt;Pickup_Postcode = substr(trim(@$rate-&gt;shipping_params-&gt;post_code),0,6); * $parcel-&gt;Destination_Postcode = substr(trim($order-&gt;shipping_address-&gt;address_post_code),0,6); *PFC added the following on 02/25/2012 */ $parcel-&gt;Pickup_Postcode = substr(preg_replace('#[^a-z0-9]#i','',@$rate-&gt;shipping_params-&gt;post_code),0,6); $parcel-&gt;Destination_Postcode = substr(preg_replace('#[^a-z0-9]#i','',$order-&gt;shipping_address-&gt;address_post_code),0,6); $parcel-&gt;Length=15; $parcel-&gt;Width=15; $parcel-&gt;Height=15; $parcel-&gt;Quantity=1; $parcel-&gt;Weight=$package_weight; //dump($parcel-&gt;Weight);

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC80MDkwMS11cy05LWRpZ2l0LXBvc3RhbC1jb2RlLXVzcHMtc2hpcHBpbmctbW9kdWxlP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86322
- Thank you received: 14281
-
-

14 years 8 months ago [\#41256](#41256) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: US 9 Digit Postal Code: USPS Shipping Module](/forum/3-bug-report/40901-us-9-digit-postal-code-usps-shipping-module#41256 "I have a small problem with the USPS shipping module? I noticed that the hyphen (-) in the US nine digit postal code causes the shipping module not to recognize it. For example postal code  19438-1059 causes a &quot;no shipping method available error&quot;  However if you enter the postal code without the hyphen like this 19438 1094 it works. Most people will enter the 9 digit postal code with the hyphen so I think the USPS Shipping Modules needs to be able to handle the presence of it.  Thank you,  Paul")*

I checked online and normally only the first 5 digits of the post code are sent to USPS. Maybe it comes from that (we didn't made the plugin which was done by another developer, so I'm just guessing to help you based on what I could find online) ?

Try like that:
$parcel-&gt;Pickup_Postcode = substr(preg_replace('#[^a-z0-9]#i','',@$rate-&gt;shipping_params-&gt;post_code),0,5);
$parcel-&gt;Destination_Postcode = substr(preg_replace('#[^a-z0-9]#i','',$order-&gt;shipping_address-&gt;address_post_code),0,5);

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC80MDkwMS11cy05LWRpZ2l0LXBvc3RhbC1jb2RlLXVzcHMtc2hpcHBpbmctbW9kdWxlP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

- **[ELHS](/forum/user/5412-elhs "View ELHS's Profile")**
- [![ELHS's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar5412.jpg)](/forum/user/5412-elhs "View ELHS's Profile") Topic Author
- [ Offline](/forum/user/5412-elhs)

Less More

- Posts: 45
- Thank you received: 1
-
-

14 years 8 months ago [\#41477](#41477) by [ELHS](/forum/user/5412-elhs "View ELHS's Profile")  Replied by *[ELHS](/forum/user/5412-elhs "View ELHS's Profile")* on topic *[Re: US 9 Digit Postal Code: USPS Shipping Module](/forum/3-bug-report/40901-us-9-digit-postal-code-usps-shipping-module#41477 "I have a small problem with the USPS shipping module? I noticed that the hyphen (-) in the US nine digit postal code causes the shipping module not to recognize it. For example postal code  19438-1059 causes a &quot;no shipping method available error&quot;  However if you enter the postal code without the hyphen like this 19438 1094 it works. Most people will enter the 9 digit postal code with the hyphen so I think the USPS Shipping Modules needs to be able to handle the presence of it.  Thank you,  Paul")*

That fixed the problem. I originally try to contact the USPS plugin provider however a dead email address is listed in the code comments.

Thank you

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC80MDkwMS11cy05LWRpZ2l0LXBvc3RhbC1jb2RlLXVzcHMtc2hpcHBpbmctbW9kdWxlP3RtcGw9bWFya2Rvd24=) or [Create an account](/register) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.095 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
