barefists Posted April 12, 2015 Share Posted April 12, 2015 (edited) Hi all, My shop is based in Singapore - addresses in my country do not have a "City" or "State" field in them. State is of course, already disabled via the switch in the backoffice, but I can't find a way to remove the required "City" field if the country selected is "Singapore". Please help. Best Regards,XM Edited April 12, 2015 by barefists (see edit history) Link to comment Share on other sites More sharing options...
jgamio Posted April 12, 2015 Share Posted April 12, 2015 Are you went to backoffice Localization -> Countries -> Edit your country Go to Address format and format your address Link to comment Share on other sites More sharing options...
PascalVG Posted April 12, 2015 Share Posted April 12, 2015 (edited) jgamio, I think he wants to dynamically remove the city input field when country == Singapore is selected, just like the State fields pops up/hides when a country with States is (un)selected. barefists, to do this: Edit file: themes/<your theme folder>/js/tools/statesManagement.js (Make backup!!) and add this red piece of code to the end of the file: function updateCity() { var idCountry = parseInt($('#id_country').val()); if (idCountry =="25" ) // 25 is Singapore's county ID (Check you own county list!) { $('#city').val( '\xa0' ); // add non-breakable space as city name $('#city').parent().fadeOut('fast'); } else if ($('#city').val() == '\xa0' ) // if we come from Singapore, // re-display and clear city name. Otherwise ignore { $('#city').val(''); $('#city').parent().fadeIn('slow'); $('#city').parent().uniform(); $('#city').focus(); // set focus to city, to make sure they type a new city name } } N.B. Make sure you check if in your shop Singapore's Country ID == 25. If not, change accordingly. Then, add two more red lines in the function function bindStateInputAndUpdate() { $('.id_state, .dni, .postcode').css({'display':'none'}); updateState(); updateNeedIDNumber(); updateZipCode(); updateCity(); $(document).on('change', '#id_country', function(e) { updateState(); updateNeedIDNumber(); updateZipCode(); updateCity(); }); ... That should do the trick. Hope this helps. pascal Edited April 12, 2015 by PascalVG (see edit history) 2 Link to comment Share on other sites More sharing options...
barefists Posted April 15, 2015 Author Share Posted April 15, 2015 Alright thanks! I'll try it out and let you know how it goes! XM Link to comment Share on other sites More sharing options...
barefists Posted April 15, 2015 Author Share Posted April 15, 2015 Tested and it work! Thanks PascalVG! XM Link to comment Share on other sites More sharing options...
prospect Posted February 25, 2017 Share Posted February 25, 2017 Maybe You know how to correct remove required "Country" field in address (Country cannot be loaded with address->id_country - OPC) 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