How to get all Regions of Country by country code in magento 2?

In Magento 2 we can get all the regions list by country code. We can get all the regions of the specific country by Country code.

Magento\Directory\Model\Country is used to getting all the regions list by the country code.

The output is an array with value, title, country code and label for regions.
Create Block file to define Country class,

call from a template file,

If country have states available in database they will display result with all the states otherwise they will returns all the regions of country in database.

For US,Result will be like,

 

Leave a Reply

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