Search by

infrangible / m2-customer-address-countries

infrangible

Separate countries for shipping and billing addresses in the checkout and the customer account: shipping addresses in the countries of Allow Countries, billing addresses in the countries of the European Union, for example for the EU geo-blocking regulation.

Package info

github.com/infrangible-dev/m2-customer-address-countries

Homepage

Type:magento2-module

pkg:composer/infrangible/m2-customer-address-countries

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

2.0.0 2026-11-30 00:37 UTC

This package is auto-updated.

Last update: 2026-11-30 01:04:09 UTC


README

Separate countries for shipping and billing addresses in the checkout and the customer account: shipping addresses are allowed in the countries the shop delivers to, billing addresses in the countries of the European Union.

This is what the EU geo-blocking regulation asks of shops that sell to customers of all member states but only ship to some of them: customers from every member state can buy with their own billing address and a shipping address in a country the shop delivers to.

Settings

Stores > Configuration > Infrangible Solutions > Customer Address Countries > General > Enable, per website and store view, "No" by default.

The countries come from General > General > Country Options:

  • Shipping addresses are allowed in the countries of Allow Countries (general/country/allow).
  • Billing addresses are allowed in the countries of European Union Countries (general/country/eu_countries). Without countries in this list, billing addresses are allowed in the same countries as shipping addresses.

Checkout

  • The country of a new shipping address offers the countries for shipping, the country of a new billing address the countries for billing, with the regions of all these countries.
  • Logged-in customers are only offered their saved addresses whose country is allowed for the type of address: the list of shipping addresses contains the addresses in countries for shipping, the selection of the billing address the addresses in countries for billing. The default shipping address or the only address of a customer is only selected if its country is allowed for shipping; without such an address, the checkout shows the form for a new shipping address.
  • The server rejects a shipping address in a country that is not allowed for shipping in the shipping step, so that the payment step cannot be reached with it, and checks both addresses again before the order is placed, also in other checkouts that place orders with Magento's quote validation (for example PayPal Express).

Customer account

  • The address form offers the countries for shipping and billing.
  • An address can only be the default shipping address if its country is allowed for shipping, and only the default billing address if its country is allowed for billing. The form disables the checkbox and shows a note below the country otherwise.
  • The server removes these default flags whenever an address is saved (in the address book, in the checkout or with the API), also of an address that was a default address before its country was changed.

For themes and modules

  • Magento's country validator of addresses accepts the countries for shipping and billing; whether a country fits the type of the address is checked by the module where the type is known (see above).
  • The billing address forms of the checkout import their countries from the dictionary country_id_billing of the checkoutProvider instead of country_id.
  • The checkout gets the countries in window.checkoutConfig.infrangibleCustomerAddressCountries (shippingCountryIds, billingCountryIds). requirejs-config.js maps Magento_Customer/js/model/address-list to the filtered lists Infrangible_CustomerAddressCountries/js/model/shipping-address-list for Magento_Checkout/js/view/shipping and Magento_Checkout/js/view/shipping-address/list, and to Infrangible_CustomerAddressCountries/js/model/billing-address-list for Magento_Checkout/js/view/billing-address and Magento_Checkout/js/view/billing-address/list; a mixin of Magento_Checkout/js/model/checkout-data-resolver resolves the shipping address from the filtered list. Checkouts that replace these components can use the same lists.

Requirements

  • Magento Open Source or Adobe Commerce 2.4.6 or newer
  • PHP 8.1 or newer

Installation

composer require infrangible/m2-customer-address-countries
bin/magento module:enable Infrangible_CustomerAddressCountries
bin/magento setup:upgrade

In production mode, also run bin/magento setup:di:compile and bin/magento setup:static-content:deploy.

License

Infrangible Customer Address Countries is licensed under the MIT License - see the LICENSE file for details.