Commit db49381afb9 for woocommerce
commit db49381afb95299b4be3d1c0a6ab1da42d220d4f
Author: Marco Almeida | Webdados <webdados@users.noreply.github.com>
Date: Tue May 5 13:32:24 2026 +0100
Add filter for shipping zone REST API response (#64246)
* Add filter for shipping zone REST API response
Added a filter to modify the shipping zone response in the REST API, allowing this endpoint to be extended.
Closes #64245
* Add changefile(s) from automation for the following project(s): woocommerce
* Update parameter description in shipping zone filter
Improve woocommerce_rest_prepare_shipping_zone php doc
---------
Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>
diff --git a/plugins/woocommerce/changelog/64246-patch-2 b/plugins/woocommerce/changelog/64246-patch-2
new file mode 100644
index 00000000000..6208ce8e248
--- /dev/null
+++ b/plugins/woocommerce/changelog/64246-patch-2
@@ -0,0 +1,4 @@
+Significance: minor
+Type: add
+
+Allow the shipping zones REST API endpoint to be extended
\ No newline at end of file
diff --git a/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-shipping-zones-v2-controller.php b/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-shipping-zones-v2-controller.php
index 7bdd68a73cf..24ce57f66d0 100644
--- a/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-shipping-zones-v2-controller.php
+++ b/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-shipping-zones-v2-controller.php
@@ -244,7 +244,16 @@ class WC_REST_Shipping_Zones_V2_Controller extends WC_REST_Shipping_Zones_Contro
$response->add_links( $this->prepare_links( $data['id'] ) );
- return $response;
+ /**
+ * Filter shipping zone objects returned from the REST API.
+ *
+ * @param WP_REST_Response $response The response object.
+ * @param array $item The shipping zone data.
+ * @param WP_REST_Request $request Request object.
+ *
+ * @since 10.9.0
+ */
+ return apply_filters( 'woocommerce_rest_prepare_shipping_zone', $response, $item, $request );
}
/**