Commit b9b47ae7c47 for woocommerce
commit b9b47ae7c471685d988ef45182eba1b8faeee18d
Author: Peerapat Pongnipakorn <39871299+Peerapatfc@users.noreply.github.com>
Date: Fri Dec 4 22:31:01 2026 +0700
Accept Polish postcodes without the hyphen in the Checkout block (#71685)
* Accept Polish postcodes without the hyphen in the Checkout block
* Add changelog entry for Polish postcode validation fix
* Add too-short and too-long Polish postcodes to the shared fixtures
The JS suite rejects 0000 and 000001 for PL, but the shared fixtures had
no invalid Polish case left once 00001 became valid, so the PHP parity
test no longer checked that PL rejects wrong lengths.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Raluca Stan <ralucastn@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
diff --git a/plugins/woocommerce/changelog/71678-fix-checkout-block-polish-postcode-without-hyphen b/plugins/woocommerce/changelog/71678-fix-checkout-block-polish-postcode-without-hyphen
new file mode 100644
index 00000000000..ebe2f1ef324
--- /dev/null
+++ b/plugins/woocommerce/changelog/71678-fix-checkout-block-polish-postcode-without-hyphen
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Accept Polish postcodes typed without the hyphen in the Checkout block, matching the classic checkout and the Store API.
diff --git a/plugins/woocommerce/client/blocks/bin/generate-postcode-validation-rules.js b/plugins/woocommerce/client/blocks/bin/generate-postcode-validation-rules.js
index f01e48614f4..df50fb8cb7d 100644
--- a/plugins/woocommerce/client/blocks/bin/generate-postcode-validation-rules.js
+++ b/plugins/woocommerce/client/blocks/bin/generate-postcode-validation-rules.js
@@ -97,6 +97,7 @@ const COMPATIBILITY_OVERRIDES = {
pattern: '[1-9][0-9]{3}\\s?(?!SA|SD|SS)[A-Z]{2}',
flags: 'i',
},
+ PL: { pattern: '\\d{2}-?\\d{3}' },
PR: { pattern: '[0-9]{5}(?:-[0-9]{4})?', flags: 'i' },
PT: { pattern: '[0-9]{4}-[0-9]{3}' },
SE: { pattern: '(?:SE-)?[0-9]{3}\\s?[0-9]{2}' },
diff --git a/plugins/woocommerce/client/blocks/packages/public-api/blocks-checkout/utils/validation/test/is-postcode.ts b/plugins/woocommerce/client/blocks/packages/public-api/blocks-checkout/utils/validation/test/is-postcode.ts
index c274c43a14e..be6298d5537 100644
--- a/plugins/woocommerce/client/blocks/packages/public-api/blocks-checkout/utils/validation/test/is-postcode.ts
+++ b/plugins/woocommerce/client/blocks/packages/public-api/blocks-checkout/utils/validation/test/is-postcode.ts
@@ -140,8 +140,11 @@ describe( 'isPostcode', () => {
[ true, '99-440', 'PL' ],
[ false, '000-01', 'PL' ],
[ false, '994-40', 'PL' ],
- [ false, '00001', 'PL' ],
- [ false, '99440', 'PL' ],
+ [ true, '00001', 'PL' ],
+ [ true, '99440', 'PL' ],
+ [ true, '00950', 'PL' ],
+ [ false, '0000', 'PL' ],
+ [ false, '000001', 'PL' ],
// Puerto Rican postcodes
[ true, '00901', 'PR' ],
diff --git a/plugins/woocommerce/client/blocks/packages/public-api/blocks-checkout/utils/validation/test/postcode-validation-fixtures.json b/plugins/woocommerce/client/blocks/packages/public-api/blocks-checkout/utils/validation/test/postcode-validation-fixtures.json
index 6b2aab6bdef..42675e2c38c 100644
--- a/plugins/woocommerce/client/blocks/packages/public-api/blocks-checkout/utils/validation/test/postcode-validation-fixtures.json
+++ b/plugins/woocommerce/client/blocks/packages/public-api/blocks-checkout/utils/validation/test/postcode-validation-fixtures.json
@@ -70,7 +70,9 @@
{ "country": "NO", "postcode": "1234", "expected": true },
{ "country": "NO", "postcode": "123", "expected": false },
{ "country": "PL", "postcode": "00-001", "expected": true },
- { "country": "PL", "postcode": "00001", "expected": false },
+ { "country": "PL", "postcode": "00001", "expected": true },
+ { "country": "PL", "postcode": "0000", "expected": false },
+ { "country": "PL", "postcode": "000001", "expected": false },
{ "country": "PR", "postcode": "12345", "expected": true },
{ "country": "PR", "postcode": "1234", "expected": false },
{ "country": "PT", "postcode": "1234-567", "expected": true },
diff --git a/plugins/woocommerce/i18n/postcode-validation-rules.json b/plugins/woocommerce/i18n/postcode-validation-rules.json
index 73ad6196868..132e06e18b2 100644
--- a/plugins/woocommerce/i18n/postcode-validation-rules.json
+++ b/plugins/woocommerce/i18n/postcode-validation-rules.json
@@ -92,7 +92,7 @@
"pattern": "\\d{4}"
},
"PL": {
- "pattern": "\\d{2}-\\d{3}"
+ "pattern": "\\d{2}-?\\d{3}"
},
"PR": {
"pattern": "[0-9]{5}(?:-[0-9]{4})?",