Magento 2: Country select field in checkout shows two empty options

Magento 2: Country select field in checkout shows two empty options

September 8, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento 2: Country select field in checkout shows two empty options

Magento 2: Resolving the Empty Country Select Options Bug in Checkout

As an experienced Magento developer, I’ve encountered a variety of issues over the years. One common problem that can frustrate both merchants and customers is the appearance of empty options in the country select field during checkout. Let me guide you through identifying this bug and providing a practical solution.

Understanding the Issue

The version 2.1.12 of Magento 2 seems to have an issue with the way the country picker is rendered on the checkout page. This results in two empty options appearing at the top of the dropdown, as illustrated in the image provided by Remco Hendriks:

Magento 2 Country Select Field Bug

Identifying the Root Cause

This bug likely stems from a conflict between the core Magento code and any customizations or third-party extensions you might have installed. The issue arises during the rendering of the checkout form, where the country options are populated.

Step-by-Step Solution

To resolve this issue without needing to dive deep into the core codebase, we can leverage Magento’s plugin system. Here’s a straightforward approach:

  1. Create a custom module: First, create a new custom module in your project using Magento’s built-in module creator or manually set up the module structure.

  2. Implement a plugin for the checkout form: Override the Magento_Checkout module by creating a plugin that alters the rendering of the country select field.

Here’s an example of what the plugin code might look like:

public function afterGetCountryHtmlSelect($subject, $result)
{
    // Remove the first two empty options from the result
    $options = $result->getOptions();
    array_splice($options, 0, 2);

    // Reassign the modified options back to the select element
    $result->setOptions($options);

    return $result;
}
  1. Configure the plugin: In your custom module’s etc/di.xml file, define the plugin configuration:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Checkout\Block\Checkout\LayoutProcessor">
        <plugin type="YourCompany\Youromodule\Plugin\Checkout\LayoutProcessor"
                sortOrder="100"/>
    </type>
</config>
  1. Clear the cache and deploy: After creating the plugin, clear your Magento cache and deploy the static content to see the changes take effect.

Best Practices for Debugging

When facing issues like this in Magento 2 projects, I recommend following these best practices:

  • Always backup your database before making any code changes.
  • Enable developer mode and use the built-in debug tools.
  • Check for conflicting extensions or customizations that might be causing the issue.
  • Consult the official Magento documentation and community forums for known bugs and workarounds.

Conclusion

The empty country select options bug in the Magento 2 checkout is a common issue that can significantly impact the user experience. By leveraging Magento’s plugin system, we can create a clean, efficient solution without modifying the core codebase.

Remember, when working with Magento, always prioritize keeping your code organized and following best practices to ensure optimal performance and security.

Don’t hesitate to reach out to our expert team at Laravel Company if you need further assistance or have more complex Magento development needs. We’re here to help!

Happy coding!

Magento 2 Checkout Extensions Customers

Our network