Commit b42bcc4062f for woocommerce
commit b42bcc4062f15106aed6638a8788b712fc15744e
Author: Tom Cafferkey <tjcafferkey@gmail.com>
Date: Wed Nov 11 14:35:56 2026 +0000
Fix shipping country choices in block checkout (#70852)
* Fix shipping country choices in block checkout
* Add changelog entry for shipping country choices
diff --git a/plugins/woocommerce/client/blocks/assets/js/base/components/country-input/shipping-country-input.tsx b/plugins/woocommerce/client/blocks/assets/js/base/components/country-input/shipping-country-input.tsx
index 5ab080dda45..15a8107114c 100644
--- a/plugins/woocommerce/client/blocks/assets/js/base/components/country-input/shipping-country-input.tsx
+++ b/plugins/woocommerce/client/blocks/assets/js/base/components/country-input/shipping-country-input.tsx
@@ -1,7 +1,8 @@
/**
* External dependencies
*/
-import { COUNTRIES } from '@woocommerce/block-settings';
+import { SHIPPING_COUNTRIES } from '@woocommerce/block-settings';
+import type { ReactElement } from 'react';
/**
* Internal dependencies
@@ -9,8 +10,8 @@ import { COUNTRIES } from '@woocommerce/block-settings';
import CountryInput from './country-input';
import { CountryInputProps } from './CountryInputProps';
-const ShippingCountryInput = ( props: CountryInputProps ): JSX.Element => {
- return <CountryInput countries={ COUNTRIES } { ...props } />;
+const ShippingCountryInput = ( props: CountryInputProps ): ReactElement => {
+ return <CountryInput countries={ SHIPPING_COUNTRIES } { ...props } />;
};
export default ShippingCountryInput;
diff --git a/plugins/woocommerce/client/blocks/assets/js/base/components/country-input/test/address-country-inputs.tsx b/plugins/woocommerce/client/blocks/assets/js/base/components/country-input/test/address-country-inputs.tsx
new file mode 100644
index 00000000000..27f8120aaba
--- /dev/null
+++ b/plugins/woocommerce/client/blocks/assets/js/base/components/country-input/test/address-country-inputs.tsx
@@ -0,0 +1,48 @@
+/**
+ * External dependencies
+ */
+import { render, screen } from '@testing-library/react';
+
+/**
+ * Internal dependencies
+ */
+import ShippingCountryInput from '../shipping-country-input';
+import BillingCountryInput from '../billing-country-input';
+
+jest.mock( '@woocommerce/block-settings', () => ( {
+ ...jest.requireActual( '@woocommerce/block-settings' ),
+ SHIPPING_COUNTRIES: { ES: 'Spain' },
+ COUNTRIES: { ES: 'Spain', US: 'United States (US)' },
+} ) );
+
+const defaultProps = {
+ id: 'country',
+ label: 'Country/Region',
+ onChange: jest.fn(),
+};
+
+describe( 'Address country inputs', () => {
+ it( 'only offers shipping countries even when billing countries are also available', () => {
+ render( <ShippingCountryInput { ...defaultProps } value="ES" /> );
+
+ expect( screen.getByRole( 'option', { name: 'Spain' } ) ).toBeEnabled();
+ expect(
+ screen.queryByRole( 'option', { name: 'United States (US)' } )
+ ).not.toBeInTheDocument();
+ } );
+
+ it( 'keeps an unavailable saved shipping country visible but disabled', () => {
+ render( <ShippingCountryInput { ...defaultProps } value="US" /> );
+
+ expect( screen.getByRole( 'option', { name: 'US' } ) ).toBeDisabled();
+ expect( screen.getByRole( 'option', { name: 'Spain' } ) ).toBeEnabled();
+ } );
+
+ it( 'still offers billing countries outside the shipping area for local pickup', () => {
+ render( <BillingCountryInput { ...defaultProps } value="US" /> );
+
+ expect(
+ screen.getByRole( 'option', { name: 'United States (US)' } )
+ ).toBeEnabled();
+ } );
+} );
diff --git a/plugins/woocommerce/client/blocks/changelog/fix-66002-shipping-country-options b/plugins/woocommerce/client/blocks/changelog/fix-66002-shipping-country-options
new file mode 100644
index 00000000000..18fa29fdd29
--- /dev/null
+++ b/plugins/woocommerce/client/blocks/changelog/fix-66002-shipping-country-options
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Show only countries available for shipping in the checkout shipping address selector.