I am creating customer address in Magento 2 programatically.

In few countries the region_id is required, which can be obtained from the model \Magento\Directory\Model\Region, for example forUS country and in few countries the region is required which is a text field, for example for Italy country.

How to identify if region_id is required or region (region_name) is required for the country?

  • You can check the country list under Store->Configuration->General->State Required for. May 30, 2019 at 11:44

1 Answer 1


I have a suggestion for you. Take a look at \Magento\Directory\Helper\Data

public function getRegionData()
    return $regions;

This function will return the list of countries which have the regions are required.

You should build your own logic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.