Comment to 'How to disable Countries without deleting them?'
  • Here are some feedback. I tried both methods (Raw and Header Injection). They both work. Thank you so much. I have just noticed that there is a small thing that needs to be fixed.

    Both methods displays a warning (small error message) after loading the page, just under the Postal Code Field. Where it was supposed to be showing this message 'Address is undefined', instead there is this red cross icon in a circle with this error message: 'Address not found'. The warning appears without even entering any informationa and even when I test the code with a single country e.g: ['US']. Maybe it's because both codes you provided above remove the 'Please select...' option in the country field (I am just guessing).

    Please could you like to add back the 'Please Select...' option of the country field in both methods (Raw and Header Injection)? Maybe it will prevent the warning from appearing after laoding the page. Also when we have 2 or 3 countries in the list, it would be good to invite users to select one country by displaying the 'Please select...'option instead of preselecting a value for them in the country field.

    Last but not the least, you forgot to answer my question in my previous post. What would have been the code to use in the Raw block if we were to leave 3 countries? E.g: US, CA, GB ? Like thie code below?

    $(".bx-form-input-location-country option[value!='US, CA, GB]").remove();

    Many Thanks

    • THnx for the warm words! About your question about leaving only 3 countries. My answer from 18th of December here was about it. This line:

      $.each(['GB', 'CA', 'US'], function( iIndex, sValue ) {

      is responsible to drop all other countries from the default list. You may change it also in this way:

      $.each(['', 'GB', 'CA', 'US'], function( iIndex, sValue ) {

      to have the "Please select" variant too.