• Resolved willshak

    (@willshak)


    Hi,

    The Country drop-down HTML has a custom attribute data-country-code with the ISO two-character code for each country:

    <option value="Afghanistan" data-country-code="AF" selected="selected">Afghanistan</option>

    How do I retrieve this data-country-code value for the selected country after the form is submitted, from PHP (I’m guessing JS is needed)?

    Thanks,
    Kristian

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    HI @willshak,

    Unfortunately, the country field doesn’t record any such data, so I’m afraid there isn’t any way to retrieve it without using jQuery as you have stated.

    For example:
    jQuery("#address-1-country").find(':selected').data('country-code');

    I hope this helps with your query. Have a nice day ahead.

    Kind Regards,
    Nithin

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @willshak ,

    We haven’t heard from you for several days now – it looks like a previous suggestion helped with solving your query.

    Please feel free to re-open this ticket if needed.

    kind regards,
    Kasia

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘How to get Country ISO code?’ is closed to new replies.