Commit d4e567e9741 for woocommerce

commit d4e567e97418b190f63e177d8cf1f1cacd8128ba
Author: TowyTowy <85077986+TowyTowy@users.noreply.github.com>
Date:   Mon Jul 27 15:47:22 2026 +0200

    Only enqueue block notice styles (wc-blocks-style) when block notices are in use (#66417)

    * Only enqueue block notice styles when block notices are in use

    The Notices service gated the block notice templates behind
    wp_is_block_theme() / the woocommerce_use_block_notices_in_classic_theme
    filter, but enqueued wc-blocks-style unconditionally at wp_head on every
    front-end page. Classic themes that never opted in shipped the entire
    stylesheet unused on every page, and it could not be dequeued at normal
    priorities. Move the wp_head enqueue inside the same conditional.

    Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

    * Add changelog

    Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

    * Remove duplicate changelog fragment

    The branch carried two changelog fragments for the same change
    (fix-classic-theme-block-notice-styles and
    66417-fix-classic-theme-block-notice-styles), which would produce two
    identical lines in the release changelog. Keep the number-prefixed file
    that matches the repo convention and the changelog-auto-add bot naming.

    Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

    ---------

    Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
    Co-authored-by: Luigi Teschio <gigitux@gmail.com>

diff --git a/plugins/woocommerce/changelog/66417-fix-classic-theme-block-notice-styles b/plugins/woocommerce/changelog/66417-fix-classic-theme-block-notice-styles
new file mode 100644
index 00000000000..637c4fe641f
--- /dev/null
+++ b/plugins/woocommerce/changelog/66417-fix-classic-theme-block-notice-styles
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Only enqueue the block notice styles (wc-blocks-style) on classic themes when block notices are actually in use.
diff --git a/plugins/woocommerce/src/Blocks/Domain/Services/Notices.php b/plugins/woocommerce/src/Blocks/Domain/Services/Notices.php
index 3201bb33b6b..13f4bbc84dd 100644
--- a/plugins/woocommerce/src/Blocks/Domain/Services/Notices.php
+++ b/plugins/woocommerce/src/Blocks/Domain/Services/Notices.php
@@ -53,12 +53,12 @@ class Notices {
 				 */
 				if ( wp_is_block_theme() || apply_filters( 'woocommerce_use_block_notices_in_classic_theme', false ) ) {
 					add_filter( 'wc_get_template', [ $this, 'get_notices_template' ], 10, 5 );
+					add_action( 'wp_head', [ $this, 'enqueue_notice_styles' ] );
 				}
 			}
 		);

 		add_filter( 'woocommerce_kses_notice_allowed_tags', [ $this, 'add_kses_notice_allowed_tags' ] );
-		add_action( 'wp_head', [ $this, 'enqueue_notice_styles' ] );
 	}

 	/**