Commit 4c50f80572 for woocommerce

commit 4c50f80572e9e6dc83e48fad218a29aafdabf613
Author: Seghir Nadir <nadir.seghir@gmail.com>
Date:   Wed Dec 17 13:31:36 2025 +0100

    Refactor Order V4 embeds to use add_query_arg to handle plain and pretty permalinks (#62366)

    * Refactor order note and refund URLs in Order V4 to use add_query_arg to handle plain and pretty permanlinks

    * cast to int

    * Add changefile(s) from automation for the following project(s): woocommerce

    ---------

    Co-authored-by: github-actions <github-actions@github.com>

diff --git a/plugins/woocommerce/changelog/62366-fix-plain-embed-in-v4-orders b/plugins/woocommerce/changelog/62366-fix-plain-embed-in-v4-orders
new file mode 100644
index 0000000000..43f3e28b93
--- /dev/null
+++ b/plugins/woocommerce/changelog/62366-fix-plain-embed-in-v4-orders
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Support embeds in V4 order endpoint when using plain permalinks.
\ No newline at end of file
diff --git a/plugins/woocommerce/src/Internal/RestApi/Routes/V4/Orders/Controller.php b/plugins/woocommerce/src/Internal/RestApi/Routes/V4/Orders/Controller.php
index 698bf57622..c98e63e4c8 100644
--- a/plugins/woocommerce/src/Internal/RestApi/Routes/V4/Orders/Controller.php
+++ b/plugins/woocommerce/src/Internal/RestApi/Routes/V4/Orders/Controller.php
@@ -212,11 +212,17 @@ class Controller extends AbstractController {
 				'embeddable' => true,
 			),
 			'order-notes'     => array(
-				'href'       => rest_url( sprintf( '/%s/order-notes?order_id=%d', $this->namespace, $item->get_id() ) ),
+				'href'       => add_query_arg(
+					array( 'order_id' => (int) $item->get_id() ),
+					rest_url( sprintf( '/%s/order-notes', $this->namespace ) )
+				),
 				'embeddable' => true,
 			),
 			'refunds'         => array(
-				'href'       => rest_url( sprintf( '/%s/refunds?order_id=%d', $this->namespace, $item->get_id() ) ),
+				'href'       => add_query_arg(
+					array( 'order_id' => (int) $item->get_id() ),
+					rest_url( sprintf( '/%s/refunds', $this->namespace ) )
+				),
 				'embeddable' => true,
 			),
 		);