Commit 4b31ae74ad4 for woocommerce

commit 4b31ae74ad41649821f95017e6716d41673a20a9
Author: Mike Jolley <mike.jolley@me.com>
Date:   Thu Oct 22 12:09:36 2026 +0100

    Stop requiring a postcode or state for Macao at checkout (#70069)

    * Hide the postcode field for Macao at checkout

    Macao has no postal codes, but WooCommerce requires a postcode for Macao
    addresses because MO has no entry in the country locale. Add one that
    hides the field and makes it optional, matching Qatar, the UAE and other
    countries without postal codes.

    Closes #69961

    Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

    * Hide the state field for Macao at checkout

    * Update changelog entry for Macao address fields

    ---------

    Co-authored-by: Peerapat Pongnipakorn <peerapatfc@gmail.com>
    Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>

diff --git a/plugins/woocommerce/changelog/69961-macao-postcode-state-not-required b/plugins/woocommerce/changelog/69961-macao-postcode-state-not-required
new file mode 100644
index 00000000000..811dc301edb
--- /dev/null
+++ b/plugins/woocommerce/changelog/69961-macao-postcode-state-not-required
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Stop requiring a postcode or state for Macao at checkout, since Macao addresses use neither.
diff --git a/plugins/woocommerce/includes/class-wc-countries.php b/plugins/woocommerce/includes/class-wc-countries.php
index 1e1ecd76778..0fe7d28631d 100644
--- a/plugins/woocommerce/includes/class-wc-countries.php
+++ b/plugins/woocommerce/includes/class-wc-countries.php
@@ -1579,6 +1579,16 @@ class WC_Countries {
 								'hidden'   => true,
 							),
 						),
+						'MO' => array(
+							'postcode' => array(
+								'required' => false,
+								'hidden'   => true,
+							),
+							'state'    => array(
+								'required' => false,
+								'hidden'   => true,
+							),
+						),
 						'MQ' => array(
 							'state' => array(
 								'required' => false,
diff --git a/plugins/woocommerce/tests/php/includes/class-wc-countries-test.php b/plugins/woocommerce/tests/php/includes/class-wc-countries-test.php
index 5542e33b39a..5e3548c6ee8 100644
--- a/plugins/woocommerce/tests/php/includes/class-wc-countries-test.php
+++ b/plugins/woocommerce/tests/php/includes/class-wc-countries-test.php
@@ -992,6 +992,22 @@ class WC_Countries_Test extends \WC_Unit_Test_Case {
 		$this->assertFalse( $fields['billing_state']['hidden'] ?? false, 'Qatar follows the UAE, which keeps the state visible rather than hiding it like Bahrain and Kuwait.' );
 	}

+	/**
+	 * Macao has no postal codes or subdivisions, so the postcode and state fields are hidden and optional.
+	 *
+	 * @testdox 'get_address_fields' hides the postcode and state for Macao, which uses neither.
+	 *
+	 * @return void
+	 */
+	public function test_get_address_fields_hides_postcode_and_state_for_macao() {
+		$fields = ( new WC_Countries() )->get_address_fields( 'MO', 'billing_' );
+
+		$this->assertTrue( $fields['billing_postcode']['hidden'] ?? false, 'Macao has no postal codes, so the field should be hidden.' );
+		$this->assertFalse( $fields['billing_postcode']['required'], 'Macao has no postal codes, so the field should not be required.' );
+		$this->assertTrue( $fields['billing_state']['hidden'] ?? false, 'Macao has no subdivisions, so the state should be hidden.' );
+		$this->assertFalse( $fields['billing_state']['required'], 'Macao has no subdivisions, so the state should not be required.' );
+	}
+
 	/**
 	 * Provider for `test_get_country_from_alpha_3_code`.
 	 *