country_option_tags

country_option_tags creates an <option> tag for each country. An attribute named data-provinces is set for each country, containing JSON-encoded arrays of the country's respective subregions. If a country does not have any subregions, an empty array is set for its data-provinces attribute.

country_option_tags must be wrapped in <select> HTML tags.

Input

<select name="country">
  {{ country_option_tags }}
</select>

Output

<select name="country">
  <option value"" data-provinces="[]">- Please Select --</option>
  ...
  ...
  <option value="Canada" data-provinces="["Alberta","British Columbia","Manitoba","New Brunswick","Newfoundland","Northwest Territories","Nova Scotia","Nunavut","Ontario","Prince Edward Island","Quebec","Saskatchewan","Yukon"]">Canada</option>
  <option value="China" data-provinces="[]">China</option>
  ...
  ...
</select>

Want to discuss this page?

Visit the Shopify Community