Get Default Country code from the current website Magento 2.

Get Default Country Value from the Current Website Using Programmatic way in Magento 2.

You can get the value of default country from the admin panel,
1. Stores -> Configuration -> General -> General
2. Country Options Tab -> Default Country.
Check the Selected Country value for the current website by set Store view as website scope.

Default Country Magento 2
Default Country From Website Scope

You can get the country code for the current website by programmatically using the code snippet.

Call from the template or any PHP class,
general/country/default is the config path to retrieve country code.
echo $countryName = $this->getCountryByWebsite();

Output: (Two Digit Country code)
US (United States is selected)

Leave a Reply