Get Region Code from Region name in Magento 2.

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,