Commit b5ae2abed84 for woocommerce
commit b5ae2abed84fea665bae725f54cb22e6535cf44c
Author: Emmanuel GBAVOU <egbavou32@gmail.com>
Date: Thu Nov 5 14:01:56 2026 +0100
Hide the postcode field and label departments for Benin (#70317)
fix(checkout): hide postcode and label departments for Benin
Benin has no postal codes: mail goes to a PO box ("BP") at a
distributing post office (UPU addressing sheet, 11/2025). With no
locale entry, Benin fell back to a required postcode and a
"State / County" label.
Add a BJ locale entry, identical to Bolivia's: the postcode is hidden
and optional, and the state field is labelled "Department" and stays
required.
diff --git a/plugins/woocommerce/changelog/fix-benin-address-fields b/plugins/woocommerce/changelog/fix-benin-address-fields
new file mode 100644
index 00000000000..0b46dd401ec
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-benin-address-fields
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Hide the postcode field and label the state field "Department" for Benin addresses.
diff --git a/plugins/woocommerce/includes/class-wc-countries.php b/plugins/woocommerce/includes/class-wc-countries.php
index 2fb18187e66..11e1cbf042c 100644
--- a/plugins/woocommerce/includes/class-wc-countries.php
+++ b/plugins/woocommerce/includes/class-wc-countries.php
@@ -1187,6 +1187,15 @@ class WC_Countries {
'hidden' => true,
),
),
+ 'BJ' => array(
+ 'postcode' => array(
+ 'required' => false,
+ 'hidden' => true,
+ ),
+ 'state' => array(
+ 'label' => __( 'Department', 'woocommerce' ),
+ ),
+ ),
'BO' => array(
'postcode' => 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 b32febd2f0e..ae55661f388 100644
--- a/plugins/woocommerce/tests/php/includes/class-wc-countries-test.php
+++ b/plugins/woocommerce/tests/php/includes/class-wc-countries-test.php
@@ -1008,6 +1008,22 @@ class WC_Countries_Test extends \WC_Unit_Test_Case {
$this->assertFalse( $fields['billing_state']['required'], 'Macao has no subdivisions, so the state should not be required.' );
}
+ /**
+ * Benin has no postal codes: mail goes to a PO box ("BP") in a locality. Its 12 departments stay a required list.
+ *
+ * @testdox 'get_address_fields' hides the postcode for Benin and labels the state as a department, like Bolivia.
+ *
+ * @return void
+ */
+ public function test_get_address_fields_hides_postcode_and_labels_departments_for_benin() {
+ $fields = ( new WC_Countries() )->get_address_fields( 'BJ', 'billing_' );
+
+ $this->assertTrue( $fields['billing_postcode']['hidden'] ?? false, 'Benin has no postal codes, so the field should be hidden.' );
+ $this->assertFalse( $fields['billing_postcode']['required'], 'Benin has no postal codes, so the field should not be required.' );
+ $this->assertSame( 'Department', $fields['billing_state']['label'], 'Benin is divided into departments.' );
+ $this->assertTrue( $fields['billing_state']['required'], 'Benin keeps its required list of 12 departments.' );
+ }
+
/**
* @testdox 'get_formatted_address' outputs translated state names stored as HTML entities as text, including in uppercase.
*/