Skip to content

WooCommerce – get array of supported countries

Return an array of countries where key = code and value = name.

if(class_exists('WC_Countries') {
  $countries = new WC_Countries();
  $countries = $countries->__get('countries'); 
  print_r($countries); // [code] => name

Use in a select box

foreach($countries as $k => $v) {
  echo '<option value="'.$k.'">'.$v.'</option>';  


10 years + experience in web development working with lots of different technology.

Published inPHPWooCommerceWordPress

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *