Commit f2be448f9b4 for woocommerce

commit f2be448f9b4668f73ad6c291fa87cb9116ba5a80
Author: Albert Juhé Lluveras <contact@albertjuhe.com>
Date:   Mon Jun 15 12:36:18 2026 +0200

    Don't show color swatches in the editor if they are disabled (#65724)

    * Add line-through to disabled chips

    * Don't show color swatches in the editor if they are disabled

    * Add changelog

diff --git a/plugins/woocommerce/changelog/fix-swatches-in-editor-only-if-enabled b/plugins/woocommerce/changelog/fix-swatches-in-editor-only-if-enabled
new file mode 100644
index 00000000000..592cc88661f
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-swatches-in-editor-only-if-enabled
@@ -0,0 +1,5 @@
+Significance: patch
+Type: fix
+Comment: Don't show color swatches in the editor if they are disabled
+
+
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/add-to-cart-with-options/variation-selector/attribute/edit.tsx b/plugins/woocommerce/client/blocks/assets/js/blocks/add-to-cart-with-options/variation-selector/attribute/edit.tsx
index 38fdc41d378..47b0aca9890 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/add-to-cart-with-options/variation-selector/attribute/edit.tsx
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/add-to-cart-with-options/variation-selector/attribute/edit.tsx
@@ -35,6 +35,7 @@ import {
 	__experimentalToolsPanel as ToolsPanel,
 	__experimentalToolsPanelItem as ToolsPanelItem,
 } from '@wordpress/components';
+import { getSetting } from '@woocommerce/settings';

 /**
  * Internal dependencies
@@ -102,6 +103,10 @@ function AttributeItem( { blocks, isSelected, onSelect }: AttributeItemProps ) {
 			__experimental_visual: true,
 		},
 	} );
+	const visualAttributesEnabled = getSetting(
+		'experimentalVisualAttributes',
+		false
+	);
 	const visualByTermId = useMemo( () => {
 		return attributeTerms.reduce< Record< number, VisualAttributeTerm > >(
 			( accumulator, term ) => {
@@ -128,7 +133,10 @@ function AttributeItem( { blocks, isSelected, onSelect }: AttributeItemProps ) {
 		) {
 			items = attribute.terms.map( ( term ) => {
 				const visual =
-					visualByTermId[ term.id ] || EMPTY_TERM_VISUALS[ term.id ];
+					visualByTermId[ term.id ] ||
+					( visualAttributesEnabled
+						? EMPTY_TERM_VISUALS[ term.id ]
+						: undefined );

 				return {
 					id: `${ attribute.taxonomy }-${ term.slug }`,
@@ -150,7 +158,7 @@ function AttributeItem( { blocks, isSelected, onSelect }: AttributeItemProps ) {
 			ariaLabel: string;
 			visual?: VisualAttributeTerm;
 		} >;
-	}, [ attribute, visualByTermId ] );
+	}, [ attribute, visualAttributesEnabled, visualByTermId ] );

 	const blockPreviewProps = useBlockPreview( {
 		blocks,
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/inner-blocks/chips/style.scss b/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/inner-blocks/chips/style.scss
index da9121432c0..4a43dbc60ac 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/inner-blocks/chips/style.scss
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/product-filters/inner-blocks/chips/style.scss
@@ -67,6 +67,10 @@
 	&:hover {
 		background: transparent;
 	}
+
+	:where(.wc-block-product-filter-chips__label) {
+		text-decoration: line-through;
+	}
 }

 :where(.wc-block-product-filter-chips__label) {
diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/AddToCartWithOptions/VariationSelectorAttribute.php b/plugins/woocommerce/src/Blocks/BlockTypes/AddToCartWithOptions/VariationSelectorAttribute.php
index 26497a66d1f..d1c9231f9ec 100644
--- a/plugins/woocommerce/src/Blocks/BlockTypes/AddToCartWithOptions/VariationSelectorAttribute.php
+++ b/plugins/woocommerce/src/Blocks/BlockTypes/AddToCartWithOptions/VariationSelectorAttribute.php
@@ -22,6 +22,25 @@ class VariationSelectorAttribute extends AbstractBlock {
 	 */
 	protected $block_name = 'add-to-cart-with-options-variation-selector-attribute';

+	/**
+	 * Extra data passed through from server to client for block.
+	 *
+	 * @param array $attributes  Any attributes that currently are available from the block.
+	 *                           Note, this will be empty in the editor context when the block is
+	 *                           not in the post content on editor load.
+	 * @return void
+	 */
+	protected function enqueue_data( array $attributes = array() ): void {
+		parent::enqueue_data( $attributes );
+
+		if ( is_admin() ) {
+			$this->asset_data_registry->add(
+				'experimentalVisualAttributes',
+				array_key_exists( 'wc-visual', wc_get_attribute_types() )
+			);
+		}
+	}
+
 	/**
 	 * Render the block.
 	 *