After debuging I found a solution, I have changed from SCOPE_WEBSITE
to SCOPE_STORE
the in this file line no. 131
File path
:vendor/magento/module-customer/Model/ResourceModel/Address/Attribute/Source/CountryWithWebsites.php
Piece of code
public function getAllOptions($withEmpty = true, $defaultValues = false)
{
if (!$this->options) {
$websiteIds = [];
if (!$this->shareConfig->isGlobalScope()) {
$allowedCountries = [];
foreach ($this->storeManager->getWebsites() as $website) {
$countries = $this->allowedCountriesReader
->getAllowedCountries(ScopeInterface::SCOPE_WEBSITE, $website->getId());
$allowedCountries[] = $countries;
foreach ($countries as $countryCode) {
$websiteIds[$countryCode][] = $website->getId();
}
}
$allowedCountries = array_unique(array_merge([], ...$allowedCountries));
} else {
// Address can be added only for the allowed country list.
$storeId = null;
$customerId = $this->request->getParam('parent_id') ?? null;
if ($customerId) {
$customer = $this->customerRepository->getById($customerId);
$storeId = $customer->getStoreId();
}
$allowedCountries = $this->allowedCountriesReader->getAllowedCountries(
ScopeInterface::SCOPE_WEBSITE,
$storeId
);
}
$this->options = $this->createCountriesCollection()
->addFieldToFilter('country_id', ['in' => $allowedCountries])
->toOptionArray();
foreach ($this->options as &$option) {
if (isset($websiteIds[$option['value']])) {
$option['website_ids'] = $websiteIds[$option['value']];
}
}
}
return $this->options;
}
Replace from:-
$allowedCountries = $this->allowedCountriesReader->getAllowedCountries(
ScopeInterface::SCOPE_WEBSITE,
$storeId
);
Replace to:-
$allowedCountries = $this->allowedCountriesReader->getAllowedCountries(
ScopeInterface::SCOPE_STORE,
$storeId
);
Seems to core issue