christmascrackers Posted March 25, 2011 Share Posted March 25, 2011 Somewhere while setting up Prestashop 1.4 I had to enter the postcode in a format of either letters on numbers which were referenced as L or N. In the UK we have 4 ways of entering postcodes, LN NLL, LNN NLL, LLNN NLL and LLNL NLL (some London postcodes).We could only enter one way and chose LLNN NLL, now anyone with one of the above postcodes other than this format can not register or place an order because they get the following error:There is 1 error :1. Zip/ Postal code is invalid.Must be typed as follows: AA00 0AAAny ideas anyone?***EDIT***After 2 days I managed to work out the problem. The problem was caused after I added UK as a shipping destination. There is a postcode area which states: 'National zip code (L for a letter, N for a number and C for the Iso code), e.g., NNNNN for France. No verification if undefined.' Because it has an asterik by this field I assumed it had to be filled. It doesn't. UK users need to leave it blank 1 Link to comment Share on other sites More sharing options...
phunter121 Posted August 3, 2011 Share Posted August 3, 2011 Somewhere while setting up Prestashop 1.4 I had to enter the postcode in a format of either letters on numbers which were referenced as L or N. In the UK we have 4 ways of entering postcodes, LN NLL, LNN NLL, LLNN NLL and LLNL NLL (some London postcodes).<br/><br/>We could only enter one way and chose LLNN NLL, now anyone with one of the above postcodes other than this format can not register or place an order because they get the following error:<br/><br/>There is 1 error :<br/>1. Zip/ Postal code is invalid.<br/>Must be typed as follows: AA00 0AA<br/><br/>Any ideas anyone?<br/><br/>***EDIT***<br/><br/>After 2 days I managed to work out the problem. The problem was caused after I added UK as a shipping destination. There is a postcode area which states: 'National zip code (L for a letter, N for a number and C for the Iso code), e.g., NNNNN for France. No verification if undefined.' <br/><br/>Because it has an asterik by this field I assumed it had to be filled. It doesn't. UK users need to leave it blank Thanks for that, I cannot find a way of making the the postcode mandatory, but it does not have to be of a particular format. Any ideas? Link to comment Share on other sites More sharing options...
gtulian58 Posted November 19, 2012 Share Posted November 19, 2012 (edited) same problem, I don't really understand what did you do to solved? Could you please tell me? Edited November 19, 2012 by gtulian58 (see edit history) Link to comment Share on other sites More sharing options...
Eddyb Posted November 21, 2012 Share Posted November 21, 2012 This definitely is not solved! We need to be able to ensure that UK buyers have inserted a postcode without having to enter a zip code format in the admininstration area. As stated above there is currently no way to do this and it is causing me to lose sales, if a buyer goes through to PayPal without a postcode they come back with an error! Link to comment Share on other sites More sharing options...
PrestaHeroes USA Posted January 31, 2013 Share Posted January 31, 2013 1.4.6.2 still not solved.. good lawd...it hast he asterik, but ps at this release anyway still lets UK'ers register without the bloody zip code...I will look at this and see if I can fix to make it 'really' required. Link to comment Share on other sites More sharing options...
bronking Posted February 21, 2014 Share Posted February 21, 2014 any joy ???? (slowly but surely fed up of looking) Link to comment Share on other sites More sharing options...
bronking Posted February 21, 2014 Share Posted February 21, 2014 well after searching allday I cannot believe how many have asked about this problem accross the site, some threads started 4 yes 4 years ago and its not been addressed. I wonder if making/inventing 6 different countries (not sure what to call them yet) with the different postcode formats would be the way to go, very unproffessional but i cannot think of any other solution. unless there is a secret sociaty out there that are under orders not to divulge the answer. I also wonder how many uk prestashop owners are out there and if its such a small number that the problem has no urgency Link to comment Share on other sites More sharing options...
micho88 Posted August 12, 2014 Share Posted August 12, 2014 Go to Localization->edit country(post code to NNNN for example) Link to comment Share on other sites More sharing options...
JoelWebsites Posted January 10, 2015 Share Posted January 10, 2015 I have solved this issue. Go to Localization->edit country in admin panel then set Does it need Zip/postal code? to 'no' it will work. 1 Link to comment Share on other sites More sharing options...
Enfys Posted September 7, 2015 Share Posted September 7, 2015 This issue is still not solved. Yes it's easy to set it so that Prestashop does not require a postcode. But, I do need UK users to be required to enter a postcode in order for our shipping process to work. I also need to be able to set up validation for UK postcodes - to do this we need to be able to enter multiple postcode formats for one country. This is a basic requirement for UK shipping! Does anyone have any advice? Link to comment Share on other sites More sharing options...
chrishan Posted September 8, 2015 Share Posted September 8, 2015 I started to evaluate PS yesterday and it seems really good other than this postcode issue that came to light in my first test. Like everyone else, I've had a google and there doesn't seem to be a sensible solution ready to hand. I've cribbed together my own fix which, with the postcodes I've already tried, seems to work ok. I'm sure someone out there will find a postcode that this doesn't work for. If that is the case - then just modify and add an additional regex. My solution. Back up the file js/validate.js then modify the validate_isPostCode function to read: function validate_isPostCode(s, pattern, iso_code) { if (typeof iso_code === 'undefined' || iso_code == '') iso_code = '[A-Z]{2}'; if (typeof(pattern) == 'undefined' || pattern.length == 0) pattern = '(([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z])))) [0-9][A-Za-z]{2}))'; else { var replacements = { ' ': '(?:\ |)', '-': '(?:-|)', 'N': '[0-9]', 'L': '[a-zA-Z]', 'C': iso_code }; for (var new_value in replacements) pattern = pattern.split(new_value).join(replacements[new_value]); } var reg = new RegExp('^' + pattern + '$'); return reg.test(s); } Like I say, this seems to work for me......hope it helps. 5 Link to comment Share on other sites More sharing options...
tamarantha Posted September 12, 2015 Share Posted September 12, 2015 I am having the same problem, some countries work fine, but most of them don't. I have tried going into Localization-Countries and left the zip/postal code format field empty. I have tried the fix above, and this one: https://www.prestash...+zip +incorrect Still no luck. I had a look at http://forge.prestas...owse/PSCSX-4852 but I'm not sure how to proceed. By "You need to update your theme and more specifically this file https://raw.githubus...esManagement.js" does it mean just to to replace the statesManagement page? My version is 1.6.1.0, using the default theme and no modules other that the native modules. Any further help would be appreciated. 1 Link to comment Share on other sites More sharing options...
Enfys Posted September 17, 2015 Share Posted September 17, 2015 chrishan thanks so much, I'll give it a go ... Link to comment Share on other sites More sharing options...
tamarantha Posted September 17, 2015 Share Posted September 17, 2015 I got the zip code problem fixed by replacing my statesManagement.js page with the one at https://raw.githubus...esManagement.js Thanks gabdara. 1 Link to comment Share on other sites More sharing options...
DamarWebbing Posted September 28, 2015 Share Posted September 28, 2015 I have this problem still! Tried the StatesManagement thing aswell. I am close to giving up now and trying a different cart Losing business now. Link to comment Share on other sites More sharing options...
Enfys Posted September 28, 2015 Share Posted September 28, 2015 (edited) I think I may have an answer. It involves using the module Shipping Cost by Postcode, creating a new zone (e.g. Scottish Highlands & Islands) in the Shipping Cost By Postcode module and then entering every relevant UK postcode range manually. (I suspect there may be a quicker way to upload the postcodes, if you know where to look). So for the UK Postal service's Zone 2 (Scottish Highlands & Islands) I am entering ranges such as HS1 0AA to HS1 9ZZ, HS2 0AA to HS2 9ZZ etc. I am also entering the same without the space for people who enter it incorrectly eg HS10AA to HS19ZZ. I think this could work (fingers crossed). I will try it and let you know ... EDIT - sorry I should say, this doesn't solve the problem as stated in the original post. But if what you are trying to achieve is to get Prestashop to work with UK postcodes, so you can set different shipping services for different areas (e.g. remote Scottish postcodes) then this could be an alternative solution Edited September 28, 2015 by Enfys (see edit history) Link to comment Share on other sites More sharing options...
koyocik Posted September 30, 2015 Share Posted September 30, 2015 Fighting with it too. Maybe add simple if somewhere in the validation files? Unfortunatelly dont know php/js enough. Link to comment Share on other sites More sharing options...
a13xoo Posted October 3, 2015 Share Posted October 3, 2015 To validate any number or letter combination entered into the United Kingdom postcode field. Since lowercase is automatically corrected uppercase you need to change this in the file: js / validate.js Modify line 125: pattern = '[a-z 0-9-]+'; to pattern = '[A-Z 0-9-]+'; Then in your Prestashop back office 'Localisation / Countires' Edit United Kingdom, And leave the 'Postal code format' Blank. Hope this helps anyone XD Alex 1 Link to comment Share on other sites More sharing options...
RobbieBlokeToys Posted October 14, 2015 Share Posted October 14, 2015 (edited) I can't believe that after 4 YEARS this problem is STILL not fixed!? I'm having this problem right now, and nothing here has helped at all. No matter what I do customers cannot add a postal code in the address without it showing a RED ERROR cross next to it, and even though it still allows customers to progress with their order it is obviously going to make a lot of customers leave without completing. This is THE MOST fundamental aspect of any shopping cart system and it needs to be fixed. I can't imagine how many users have lost out on potentially thousands of sales because of this massive problem. I now have a choice, either lose sales because people can't put their post code in, or lose sales by removing the post code field entirely and confusing my customers. Please, can anyone explain how to make this infuriating error cross disappear? Edited October 14, 2015 by RobbieBlokeToys (see edit history) Link to comment Share on other sites More sharing options...
RobbieBlokeToys Posted October 14, 2015 Share Posted October 14, 2015 Anyone? All I need is to make the postcode field visible but not required, this shouldn't be too difficult to do but I can't find any information anywhere about this. Obviously the error has persisted for 4 years without being remedied, so the best we can hope for now is to just get rid of the error warning when a customer tries to fill out the form. My customers can proceed with that warning showing and it registers them anyway, I just know that I'm now going to be missing out on potentially thousands of £'s in sales as customers see that warning and leave thinking they can't complete the order. Can no one from PS tell us how to make the postcode field visible but NOT REQUIRED? Please!? Link to comment Share on other sites More sharing options...
RobbieBlokeToys Posted October 23, 2015 Share Posted October 23, 2015 After more than a week of getting no information or advice on this I have managed to sort this out myself. Thanks for nothing PS! Chrishan's method of altering the .js worked for me, but you need to make sure you have not added anything into the postcode format field under countries > United Kingdom, and that you have Postcode Required set to visible, and that you have the postcode option in the list of fields for customers to use in the box below everything I just said. And as I said before, this is really bad PS, this is a core function of any retail platform and you've really messed this up big time by making it far too complex and open to failure. The ordering process should be the simplest thing in any ecommerce program, without it all the pretty little functions are completely meaningless. This needs to be changed so that such an important part of order creation doesn't require ten other settings to be perfectly spot on. All you need to do is give users the ability to create a custom form for the checkout process, one that doesn't rely on various other combinations of things to work as it should. Link to comment Share on other sites More sharing options...
MrsDusty Posted October 27, 2015 Share Posted October 27, 2015 (edited) I started to evaluate PS yesterday and it seems really good other than this postcode issue that came to light in my first test. Like everyone else, I've had a google and there doesn't seem to be a sensible solution ready to hand. I've cribbed together my own fix which, with the postcodes I've already tried, seems to work ok. I'm sure someone out there will find a postcode that this doesn't work for. If that is the case - then just modify and add an additional regex. My solution. Back up the file js/validate.js then modify the validate_isPostCode function to read: function validate_isPostCode(s, pattern, iso_code){ if (typeof iso_code === 'undefined' || iso_code == '') iso_code = '[A-Z]{2}'; if (typeof(pattern) == 'undefined' || pattern.length == 0) pattern = '(([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z])))) [0-9][A-Za-z]{2}))'; else { var replacements = { ' ': '(?:\ |)', '-': '(?:-|)', 'N': '[0-9]', 'L': '[a-zA-Z]', 'C': iso_code }; for (var new_value in replacements) pattern = pattern.split(new_value).join(replacements[new_value]); } var reg = new RegExp('^' + pattern + '$'); return reg.test(s);}Like I say, this seems to work for me......hope it helps. This worked for me. Thank you so much, I was on the point of giving up. Edited October 27, 2015 by MrsDusty (see edit history) Link to comment Share on other sites More sharing options...
gunril Posted December 3, 2015 Share Posted December 3, 2015 Hello, Maybe a little bit late but i changed the file statesmanagement.js (In your theme - js folder - Tools) with the following code and works till now without any problems. It's the same file earlier mentioned in this form but they forgot to put in the function binduniform so the checkboxes where not correct. Here you have the whole file : (Please copy first the original statesmanagement.js file and change it then with this one) statesmanagement.txt 3 Link to comment Share on other sites More sharing options...
Ed van der Meer Posted January 7, 2016 Share Posted January 7, 2016 Hello, Maybe a little bit late but i changed the file statesmanagement.js (In your theme - js folder - Tools) with the following code and works till now without any problems. It's the same file earlier mentioned in this form but they forgot to put in the function binduniform so the checkboxes where not correct. Here you have the whole file : (Please copy first the original statesmanagement.js file and change it then with this one) Yes that worked for me wel. I'm in the Netherlands! Link to comment Share on other sites More sharing options...
gunril Posted January 8, 2016 Share Posted January 8, 2016 Hello Ed, You're welcome of met veel plezier :-) 1 Link to comment Share on other sites More sharing options...
sangeetha Posted January 20, 2016 Share Posted January 20, 2016 Hello RobbieBlokeToys, Go to js/validate.js => function validate_isPostCode(s, pattern){ if (typeof(pattern) == 'undefined' || pattern.length == 0) pattern = '[a-z 0-9-]+'; else { var replacements = { ' ': '( |)', '-': '(-|)', 'N': '[0-9]', 'L': '[a-zA-Z]' }; for (var new_value in replacements) pattern = pattern.split(new_value).join(replacements[new_value]); } var reg = new RegExp('^'+pattern+'$', 'i'); return reg.test(s);} and also go to bottom of the same file:- $(document).on('focusout', 'input.validate, textarea.validate', function() { if ($(this).hasClass('is_required') || $(this).val().length) { if ($(this).attr('name') == 'postcode' && typeof(countriesNeedZipCode[$('#id_country option:selected').val()]) != 'undefined') var result = window['validate_'+$(this).attr('data-validate')]($(this).val(), countriesNeedZipCode[$('#id_country option:selected').val()]); else var result = window['validate_'+$(this).attr('data-validate')]($(this).val()) if (result) $(this).parent().removeClass('form-error').addClass('form-ok'); else $(this).parent().addClass('form-error').removeClass('form-ok'); }}); Link to comment Share on other sites More sharing options...
midlandsvaping Posted March 4, 2016 Share Posted March 4, 2016 Hoping it will help! Link to comment Share on other sites More sharing options...
zombie process Posted May 2, 2016 Share Posted May 2, 2016 (edited) Actually you don't need to tamper with the validate.js. Try this: At the end of the setCountries function in statesManagement.js, comment out the countries = countriesPS; assignement. Then look for the updateState function. The lines if (typeof states !== 'undefined') { $(states).each(function(key, item){ $('#id_state' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).append('<option value="' + parseInt(item.id) + '"' + (idSelectedCountry === item.id ? ' selected="selected"' : '') + '>' + item.name + '</option>'); should be if (typeof states !== 'undefined' && states.states.length && parseInt(states.contains_states)) { $(states.states).each(function(key, item){ $('#id_state' + (typeof suffix !== 'undefined' ? '_' + suffix : '')).append('<option value="' + parseInt(item.id_state) + '"' + (idSelectedState === item.id_state ? ' selected="selected"' : '') + '>' + item.name + '</option>'); }); Edited May 3, 2016 by zombie process (see edit history) Link to comment Share on other sites More sharing options...
David Eschmeyer Posted May 16, 2016 Share Posted May 16, 2016 on the store i was just looking at, i replaced the /themes/themename/js/tools/statesmanagement.js with the statesmanagement.js from the defaullt-bootstrap of 1.6.1.5 and the problem is solved. It makes sense the problem comes out for some, it may have been an early on 1.6 bug perhaps. When people build themes based on the early theme and it has a bug, they suffer with it because store updates will not fix a theme error (unless it is the default-bootstrap and you choose to have the upgrade update the theme). 1 Link to comment Share on other sites More sharing options...
Juras Posted July 3, 2016 Share Posted July 3, 2016 on the store i was just looking at, i replaced the /themes/themename/js/tools/statesmanagement.js with the statesmanagement.js from the defaullt-bootstrap of 1.6.1.5 and the problem is solved. It makes sense the problem comes out for some, it may have been an early on 1.6 bug perhaps. When people build themes based on the early theme and it has a bug, they suffer with it because store updates will not fix a theme error. That one works for me. Thanks! Link to comment Share on other sites More sharing options...
DGRL Posted August 27, 2016 Share Posted August 27, 2016 (edited) This is fixed i can confirm as i tested it myself as i cant paste a url for some strange reason and i cant even make a hyperlink search for [-] FO :Fix bug #PSCSX-5077, Country ISO code js validation. search on github regards ps í tested this on 1.6.1.6 I hope prestashop will add this to there own code There statement of not editing files coz of future updates makes this fix useless for some of us Edited August 27, 2016 by DGRL (see edit history) Link to comment Share on other sites More sharing options...
Er_sanjay Posted January 2, 2022 Share Posted January 2, 2022 On 8/28/2016 at 4:54 AM, DGRL said: This is fixed i can confirm as i tested it myself as i cant paste a url for some strange reason and i cant even make a hyperlink search for [-] FO :Fix bug #PSCSX-5077, Country ISO code js validation. search on github regards ps í tested this on 1.6.1.6 I hope prestashop will add this to there own code There statement of not editing files coz of future updates makes this fix useless for some of us Hi i am facing same issue again. on prestashop 1.7.8.2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now