How to display only the countries you ship to on checkout in magento?

How to display only the countries you ship to on checkout in magento?

July 19, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to display only the countries you ship to on checkout in magento?

Displaying Only Relevant Countries on Checkout in Magento

As an e-commerce developer, I often encounter clients who want to restrict shipping options based on their business needs. If you only ship to specific EU countries plus EEA, streamlining the checkout process for your customers is essential.

The default Magento configuration allows customers to select from a global list of countries during checkout, which can be overwhelming if your service area is limited. Let’s explore how to customize this experience.

Understanding the Current Setup

When you enable “Ship to specific countries” in the Configuration menu (Stores > Settings > Configuration > Sales > Shipping Methods), Magento indeed restricts the shipping options. However, on the checkout page, customers still face a dropdown list of all possible countries worldwide.

The key lies in customizing the frontend layout and view files to display only your target regions without affecting the core functionality.

Step 1: Create a Custom Module

To avoid modifying core files (which is generally discouraged), let’s create a custom module. Navigate to app/code and create a new directory named your_module_name, following the Magento naming convention for modules.

Step 2: Define Module Information

Create an xml file named registration.php inside the setup folder:

<?php

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Your_Module_Name',
    __DIR__
);

This file registers your module with Magento.

Step 3: Override the Checkout Layout

In the view folder, create a frontend layout file named checkout_index_index.xml and add the following code:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <update handle="sales_order_index_index"/>
    <body>
        <referenceBlock name="country_fieldset">
            <action method="setCountryOptions">
                <argument name="countries" xsi:type="array">
                    <item name="0" xsi:type="string">AT</item> <!-- Austria -->
                    <item name="1" xsi:type="string">BE</item>
                    <!-- Add all 30 countries you ship to -->
                </argument>
            </action>
        </referenceBlock>
    </body>
</page>

This code overrides the country options for the checkout form. Replace AT and BE with the two-letter abbreviations of all 28 EU countries plus EEA that you support.

Step 4: Compile and Enable Your Module

Use Magento’s setup:di:compile command to compile your module. Then, enable it via app/etc/modules/your_module_name.xml:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Your_Module_Name" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Checkout"/>
        </sequence>
    </module>
</config>

Conclusion

By following this guide, you’ve successfully customized the checkout process to display only the countries your business ships to. This streamlines the user experience and reduces confusion during the ordering process.

Remember, maintaining a clean codebase is crucial for easy updates and future customizations. Always aim to use Magento’s extension points and avoid modifying core files when possible.

If you need further assistance with Magento development or have other e-commerce questions, feel free to explore our services at Laravel Company. We’re here to help optimize your online store!

Happy coding!

Checkout API Extensions Themes

Our network