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

#   Postcode validation rules - different per country?

##

- **[brodders](/forum/user/53496-brodders "View brodders's Profile")**
- [![brodders's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/53496-brodders "View brodders's Profile") Topic Author
- [ Offline](/forum/user/53496-brodders)

Less More

- Posts: 15
- Thank you received: 2
-
-

8 years 11 months ago [\#281448](#281448) by [brodders](/forum/user/53496-brodders "View brodders's Profile")  *[Postcode validation rules - different per country?](/forum/27-checkout/892558-postcode-validation-rules-different-per-country#281448 "Hi,  We have added a postcode validation regex rule to help ensure postcodes are entered correctly, but the occasional order from users outside our country encounter issues with this as their postcodes follow a different format.  Is there a way to define different postcode validation rules per country? Alternatively could we limit the postcode regex to a single country and allow all other countries to enter without validation?  Thanks!")* was created by *[brodders](/forum/user/53496-brodders "View brodders's Profile")*

Hi,

We have added a postcode validation regex rule to help ensure postcodes are entered correctly, but the occasional order from users outside our country encounter issues with this as their postcodes follow a different format.

Is there a way to define different postcode validation rules per country? Alternatively could we limit the postcode regex to a single country and allow all other countries to enter without validation?

Thanks!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2NoZWNrb3V0Lzg5MjU1OC1wb3N0Y29kZS12YWxpZGF0aW9uLXJ1bGVzLWRpZmZlcmVudC1wZXItY291bnRyeT90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) 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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86283
- Thank you received: 14263
-
-

8 years 11 months ago [\#281452](#281452) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Postcode validation rules - different per country?](/forum/27-checkout/892558-postcode-validation-rules-different-per-country#281452 "Hi,  We have added a postcode validation regex rule to help ensure postcodes are entered correctly, but the occasional order from users outside our country encounter issues with this as their postcodes follow a different format.  Is there a way to define different postcode validation rules per country? Alternatively could we limit the postcode regex to a single country and allow all other countries to enter without validation?  Thanks!")*

Hi,

There is no such mechanism. I would recommend not restricting the post code to any ruler as a simple solution because it can vary greatly from one country to the other.
If you really need to add custom rules varying based on the country, I would recommend developing a small HikaShop plugin implementing the "onBeforeAddressCreate" and "onBeforeAddressUpdate" triggers where you'll be able to check for the validity of the post code based on the country selected.
[ www.hikashop.com/support/documentation/6...ntation.html#address](https://www.hikashop.com/support/documentation/62-hikashop-developer-documentation.html#address)
If you're a developer, it should not be a problem. Otherwise, you can always contact our partners for such development.
[ www.hikashop.com/home/our-partners.html](https://www.hikashop.com/home/our-partners.html)

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2NoZWNrb3V0Lzg5MjU1OC1wb3N0Y29kZS12YWxpZGF0aW9uLXJ1bGVzLWRpZmZlcmVudC1wZXItY291bnRyeT90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[brodders](/forum/user/53496-brodders "View brodders's Profile")**
- [![brodders's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/53496-brodders "View brodders's Profile") Topic Author
- [ Offline](/forum/user/53496-brodders)

Less More

- Posts: 15
- Thank you received: 2
-
-

8 years 6 months ago [\#291258](#291258) by [brodders](/forum/user/53496-brodders "View brodders's Profile")  Replied by *[brodders](/forum/user/53496-brodders "View brodders's Profile")* on topic *[Postcode validation rules - different per country?](/forum/27-checkout/892558-postcode-validation-rules-different-per-country#291258 "Hi,  We have added a postcode validation regex rule to help ensure postcodes are entered correctly, but the occasional order from users outside our country encounter issues with this as their postcodes follow a different format.  Is there a way to define different postcode validation rules per country? Alternatively could we limit the postcode regex to a single country and allow all other countries to enter without validation?  Thanks!")*

This was really useful and we successfully implemented this approach (using &#96;onBeforeAddressUpdate&#96; and &#96;onBeforeAddressCreate&#96; to capture the country and postcode on form submit, to apply country specific postcode validation). We were using legacy checkout and used &#96;JError::raiseWarning&#96; to return an error to the user if the postcode didn’t pass validation. All worked well.

We are now in the process of moving away from the legacy checkout to the newer code, and are struggling to output our custom postcode validation error messages.

Looking at the documentation we can't see a way to do this in the address API. However, the shipping API (for example) looks like it has a &#96;$messages&#96; variable available to send info back. Is there something like this for the address API which we have somehow missed?

FYI we are currently using Hikashop 3.2 Business Edition, but are looking to upgrade to 3.4 soon.

Thanks again.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2NoZWNrb3V0Lzg5MjU1OC1wb3N0Y29kZS12YWxpZGF0aW9uLXJ1bGVzLWRpZmZlcmVudC1wZXItY291bnRyeT90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) 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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86283
- Thank you received: 14263
-
-

8 years 6 months ago [\#291260](#291260) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Postcode validation rules - different per country?](/forum/27-checkout/892558-postcode-validation-rules-different-per-country#291260 "Hi,  We have added a postcode validation regex rule to help ensure postcodes are entered correctly, but the occasional order from users outside our country encounter issues with this as their postcodes follow a different format.  Is there a way to define different postcode validation rules per country? Alternatively could we limit the postcode regex to a single country and allow all other countries to enter without validation?  Thanks!")*

Hi,

There were issues with error messages not displaying properly in some cases with the new checkout.
So upgrading is a good idea.
But I'm not sure it will help.
I've looked a the code of the new checkout for that particular area, and I think it's missing some code if we want to handle the display of messages added by 3rd party plugins.
For that, we'll need to add that code:
[ monosnap.com/file/tUNMX47HcLj9Q7XIuBqA4V8lfFVpx5](https://monosnap.com/file/tUNMX47HcLj9Q7XIuBqA4V8lfFVpx5)
in the file administrator/components/com_hikashop/helpers/checkout/address.php
Let us know how that goes for you with these modifications so that we can push that for the next version of HikaShop.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2NoZWNrb3V0Lzg5MjU1OC1wb3N0Y29kZS12YWxpZGF0aW9uLXJ1bGVzLWRpZmZlcmVudC1wZXItY291bnRyeT90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[brodders](/forum/user/53496-brodders "View brodders's Profile")**
- [![brodders's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/53496-brodders "View brodders's Profile") Topic Author
- [ Offline](/forum/user/53496-brodders)

Less More

- Posts: 15
- Thank you received: 2
-
-

8 years 6 months ago [\#291318](#291318) by [brodders](/forum/user/53496-brodders "View brodders's Profile")  Replied by *[brodders](/forum/user/53496-brodders "View brodders's Profile")* on topic *[Postcode validation rules - different per country?](/forum/27-checkout/892558-postcode-validation-rules-different-per-country#291318 "Hi,  We have added a postcode validation regex rule to help ensure postcodes are entered correctly, but the occasional order from users outside our country encounter issues with this as their postcodes follow a different format.  Is there a way to define different postcode validation rules per country? Alternatively could we limit the postcode regex to a single country and allow all other countries to enter without validation?  Thanks!")*

Hi Nicolas,

Thanks for your kind reply. The change you gave for file administrator/components/com_hikashop/helpers/checkout/address.php has worked well.

It would be great these changes were included in next version of Hikashop as you suggested.

Thanks again for your support!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2NoZWNrb3V0Lzg5MjU1OC1wb3N0Y29kZS12YWxpZGF0aW9uLXJ1bGVzLWRpZmZlcmVudC1wZXItY291bnRyeT90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) 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)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86283
- Thank you received: 14263
-
-

8 years 6 months ago [\#291319](#291319) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Postcode validation rules - different per country?](/forum/27-checkout/892558-postcode-validation-rules-different-per-country#291319 "Hi,  We have added a postcode validation regex rule to help ensure postcodes are entered correctly, but the occasional order from users outside our country encounter issues with this as their postcodes follow a different format.  Is there a way to define different postcode validation rules per country? Alternatively could we limit the postcode regex to a single country and allow all other countries to enter without validation?  Thanks!")*

Hi,

Thanks, we'll do that !

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2NoZWNrb3V0Lzg5MjU1OC1wb3N0Y29kZS12YWxpZGF0aW9uLXJ1bGVzLWRpZmZlcmVudC1wZXItY291bnRyeT90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) 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.245 seconds

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

[](#top)
