I have set default country as UK in admin, after the configuration is done, In checkout one empty drop down is showing before the UK country.
so I have used below plugin to remove that empty dropdown.
di.xml
<type name="Magento\Directory\Model\ResourceModel\Country\Collection">
<plugin name="country_empty_dropdowns" type="Vendor\Module\Plugin\Country\Collection" sortOrder="1" disabled="false" />
</type>
Collection.php
namespace Vendor\Module\Plugin\Country;
class Collection
{
/**
* Arguments processing.
*
* @param \Magento\Directory\Model\ResourceModel\Country\Collection $subject
* @param bool $emptyLabel
*
* @return bool|array
*/
public function beforeToOptionArray(
\Magento\Directory\Model\ResourceModel\Country\Collection $subject,
$emptyLabel = null
) {
return is_null($emptyLabel) ? [''] : null;
}
}
Seems code is correct, but still i can see empty dropdown before the default country in checkout as well as in cart page.
Please anyone look into it and update your thoughts. Thanks