venditdevs Posted July 5, 2016 Share Posted July 5, 2016 Hi,In validate.js there is this code: function validate_field(that) { if ($(that).hasClass('is_required') || $(that).val().length) { if ($(that).attr('data-validate') == 'isPostCode') { var selector = '#id_country'; if ($(that).attr('name') == 'postcode_invoice') selector += '_invoice'; var id_country = $(selector + ' option:selected').val(); if (typeof(countriesNeedZipCode[id_country]) != 'undefined' && typeof(countries[id_country]) != 'undefined') var result = window['validate_'+$(that).attr('data-validate')]($(that).val(), countriesNeedZipCode[id_country], countries[id_country]['iso_code']); } else if($(that).attr('data-validate')) var result = window['validate_' + $(that).attr('data-validate')]($(that).val()); if (result) $(that).parent().removeClass('form-error').addClass('form-ok'); else $(that).parent().addClass('form-error').removeClass('form-ok'); } } $(document).on('focusout', 'input.validate, textarea.validate', function() { validate_field(this); }); But the validation fails on empty var 'countries' when you need to check on postcode/zipcodeIf i do this: $(document).on('focusout', 'input.validate, textarea.validate', function() { console.log(countries); validate_field(this); }); It gives an empty arrayIf i do this: $(document).ready(function(){ console.log(countries); $(document).on('focusout', 'input.validate, textarea.validate', function() { console.log(countries); validate_field(this); }); }); It gives me 1 filled array(the first) and 1 empty (the second)If i set a console.log to output 'countries' in the validate_field function it also logs an empty array.Seems to be failing on all our Prestashop installations ( with various different templates )Any help/fix would be appreciated. Link to comment Share on other sites More sharing options...
venditdevs Posted July 5, 2016 Author Share Posted July 5, 2016 After 2 days i've finally found it i think. In another theme js file i've found this line in a function : countries = countriesPS Commented it and it works now. 2 Link to comment Share on other sites More sharing options...
Rodilard Posted March 19, 2017 Share Posted March 19, 2017 Thanks @venditdevs. I can confirm that the file /themes/YOUR_THEME/js/tools/statesManagement.js is causing the issue. It looks like it has been written to manage US zipcode only and overwrites any other country. 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