Get Region Code by Region name in Magento 2.

Magento 2 You can get Region Code by Region name using Directory Module.

You can get region code from region name by Magento\Directory\Model\ResourceModel\Region\CollectionFactory object.

Let’s check with Region name is California and we want to get region code CA from California.

Call $this->getRegionCode(“California”);

Result will be,