Commit 738f4e169f for woocommerce

commit 738f4e169fefc12ba3c5cc6bee252a6718bc7b2c
Author: Kathy <507025+helgatheviking@users.noreply.github.com>
Date:   Thu Jan 15 07:29:03 2026 -0500

    Use vanilla JS to replace order_notes after ajax updates. Closes #60912. (#60913)

    * Use vanilla JS to replace order_notes after ajax updates. Closes #60912.

    * add null guarding

    * add changelog

    * coderabbit nitpick... check response.data exists first

    ---------

    Co-authored-by: Michael Pretty <prettyboymp@users.noreply.github.com>

diff --git a/plugins/woocommerce/changelog/dev-update-order-notes-with-vanilla-JS b/plugins/woocommerce/changelog/dev-update-order-notes-with-vanilla-JS
new file mode 100644
index 0000000000..3af7a5ace5
--- /dev/null
+++ b/plugins/woocommerce/changelog/dev-update-order-notes-with-vanilla-JS
@@ -0,0 +1,4 @@
+Significance: patch
+Type: enhancement
+
+Use vanilla JS to replace order_notes after ajax updates
diff --git a/plugins/woocommerce/client/legacy/js/admin/meta-boxes-order.js b/plugins/woocommerce/client/legacy/js/admin/meta-boxes-order.js
index 749eb39201..8e0aec6c76 100644
--- a/plugins/woocommerce/client/legacy/js/admin/meta-boxes-order.js
+++ b/plugins/woocommerce/client/legacy/js/admin/meta-boxes-order.js
@@ -490,9 +490,9 @@ jQuery( function ( $ ) {
 							$( '#woocommerce-order-items' ).find( '.inside' ).append( response.data.html );

 							// Update notes.
-							if ( response.data.notes_html ) {
-								$( 'ul.order_notes' ).empty();
-								$( 'ul.order_notes' ).append( $( response.data.notes_html ).find( 'li' ) );
+							const notesEl = document.querySelector( '#woocommerce-order-notes ul.order_notes' );
+							if ( notesEl && response.data && typeof response.data.notes_html === 'string' ) {
+								notesEl.outerHTML = response.data.notes_html;
 							}

 							wc_meta_boxes_order_items.reloaded_items();
@@ -735,9 +735,9 @@ jQuery( function ( $ ) {
 							$( '#woocommerce-order-items' ).find( '.inside' ).append( response.data.html );

 							// Update notes.
-							if ( response.data.notes_html ) {
-								$( 'ul.order_notes' ).empty();
-								$( 'ul.order_notes' ).append( $( response.data.notes_html ).find( 'li' ) );
+							const notesEl = document.querySelector( '#woocommerce-order-notes ul.order_notes' );
+							if ( notesEl && response.data && typeof response.data.notes_html === 'string' ) {
+								notesEl.outerHTML = response.data.notes_html;
 							}

 							wc_meta_boxes_order_items.reloaded_items();
@@ -1260,9 +1260,9 @@ jQuery( function ( $ ) {
 							$( '#woocommerce-order-items' ).find( '.inside' ).append( response.data.html );

 							// Update notes.
-							if ( response.data.notes_html ) {
-								$( 'ul.order_notes' ).empty();
-								$( 'ul.order_notes' ).append( $( response.data.notes_html ).find( 'li' ) );
+							const notesEl = document.querySelector( '#woocommerce-order-notes ul.order_notes' );
+							if ( notesEl && response.data && typeof response.data.notes_html === 'string' ) {
+								notesEl.outerHTML = response.data.notes_html;
 							}

 							wc_meta_boxes_order_items.reloaded_items();