Commit 1a58491512f for woocommerce
commit 1a58491512fe0764f23b0f6619bf80b98c1eb22e
Author: Taha Paksu <3295+tpaksu@users.noreply.github.com>
Date: Fri Mar 13 23:48:27 2026 +0300
Fix: Make zone locations optional in V4 Shipping Zones API (#63685)
* fix: make zone locations optional in item schema
* Add changefile(s) from automation for the following project(s): woocommerce
* test: update test for creating shipping zone without required locations
* fix: update description for zone locations to clarify "Everywhere" option
---------
Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>
diff --git a/plugins/woocommerce/changelog/63685-fix-woo13-190-i-cant-add-a-zone-for-everywhere b/plugins/woocommerce/changelog/63685-fix-woo13-190-i-cant-add-a-zone-for-everywhere
new file mode 100644
index 00000000000..5f94f310f31
--- /dev/null
+++ b/plugins/woocommerce/changelog/63685-fix-woo13-190-i-cant-add-a-zone-for-everywhere
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Make zone locations optional in the V4 Shipping Zones REST API schema so that "Everywhere" zones can be created without providing a locations array.
\ No newline at end of file
diff --git a/plugins/woocommerce/src/Internal/RestApi/Routes/V4/ShippingZones/ShippingZoneSchema.php b/plugins/woocommerce/src/Internal/RestApi/Routes/V4/ShippingZones/ShippingZoneSchema.php
index 3ffbf128f59..69dbc1497a6 100644
--- a/plugins/woocommerce/src/Internal/RestApi/Routes/V4/ShippingZones/ShippingZoneSchema.php
+++ b/plugins/woocommerce/src/Internal/RestApi/Routes/V4/ShippingZones/ShippingZoneSchema.php
@@ -53,10 +53,10 @@ class ShippingZoneSchema extends AbstractSchema {
'default' => 0,
),
'locations' => array(
- 'description' => __( 'Array of locations for this zone. Can be empty array but must be explicitly provided.', 'woocommerce' ),
+ 'description' => __( 'Array of locations for this zone. Omit or pass an empty array for an "Everywhere" zone.', 'woocommerce' ),
'type' => 'array',
'context' => array( 'view', 'edit' ),
- 'required' => true,
+ 'required' => false,
'items' => array(
'type' => 'object',
'properties' => array(
diff --git a/plugins/woocommerce/tests/php/includes/rest-api/Controllers/Version4/ShippingZones/class-wc-rest-shipping-zones-v4-controller-tests.php b/plugins/woocommerce/tests/php/includes/rest-api/Controllers/Version4/ShippingZones/class-wc-rest-shipping-zones-v4-controller-tests.php
index 196b73142f9..ab0d91e3cd5 100644
--- a/plugins/woocommerce/tests/php/includes/rest-api/Controllers/Version4/ShippingZones/class-wc-rest-shipping-zones-v4-controller-tests.php
+++ b/plugins/woocommerce/tests/php/includes/rest-api/Controllers/Version4/ShippingZones/class-wc-rest-shipping-zones-v4-controller-tests.php
@@ -888,7 +888,7 @@ class WC_REST_Shipping_Zones_V4_Controller_Tests extends WC_REST_Unit_Test_Case
}
/**
- * @testdox Should create zone without required locations.
+ * @testdox Should create zone without locations (e.g. "Everywhere" zone).
*/
public function test_create_item_missing_locations() {
$request = new WP_REST_Request( 'POST', '/wc/v4/shipping-zones' );
@@ -901,9 +901,9 @@ class WC_REST_Shipping_Zones_V4_Controller_Tests extends WC_REST_Unit_Test_Case
$response = $this->server->dispatch( $request );
$data = $response->get_data();
- $this->assertEquals( 400, $response->get_status() );
- $this->assertArrayHasKey( 'code', $data );
- $this->assertEquals( 'rest_missing_callback_param', $data['code'] );
+ $this->assertEquals( 201, $response->get_status() );
+ $this->assertEquals( 'Test Zone', $data['name'] );
+ $this->assertEmpty( $data['locations'] );
}
/**