Commit d07b7cd1a5 for woocommerce
commit d07b7cd1a5c8daa74588bce58fabab0e477edb61
Author: Albert Juhé Lluveras <contact@albertjuhe.com>
Date: Tue Dec 9 09:52:32 2025 +0100
Set Product Categories as the preferred taxonomy for the Breadcrumbs block (#62283)
* Set Product Categories as the prefered taxonomy for the Breadcrumbs block
* Add changelog file
* Typo: 'prefered' -> 'preferred'
* Mark method as internal
* Add type validation
diff --git a/plugins/woocommerce/changelog/fix-breadcrumbs-product_cat-taxonomy b/plugins/woocommerce/changelog/fix-breadcrumbs-product_cat-taxonomy
new file mode 100644
index 0000000000..02c083bbb2
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-breadcrumbs-product_cat-taxonomy
@@ -0,0 +1,4 @@
+Significance: patch
+Type: add
+
+Set Product Categories as the preferred taxonomy for the Breadcrumbs block
diff --git a/plugins/woocommerce/src/Blocks/BlockTypesController.php b/plugins/woocommerce/src/Blocks/BlockTypesController.php
index fb998ccd01..f94db5b443 100644
--- a/plugins/woocommerce/src/Blocks/BlockTypesController.php
+++ b/plugins/woocommerce/src/Blocks/BlockTypesController.php
@@ -63,6 +63,7 @@ final class BlockTypesController {
add_filter( 'widget_types_to_hide_from_legacy_widget_block', array( $this, 'hide_legacy_widgets_with_block_equivalent' ) );
add_action( 'woocommerce_delete_product_transients', array( $this, 'delete_product_transients' ) );
add_filter( 'register_block_type_args', array( $this, 'enqueue_block_style_for_classic_themes' ), 10, 2 );
+ add_filter( 'block_core_breadcrumbs_post_type_settings', array( $this, 'set_product_breadcrumbs_preferred_taxonomy' ), 10, 2 );
}
/**
@@ -667,4 +668,22 @@ final class BlockTypesController {
return $args;
}
+
+ /**
+ * Change the preferred taxonomy for the breadcrumbs block on the product post type.
+ *
+ * @param array $settings The settings for the breadcrumbs block.
+ * @param string $post_type The post type.
+ * @return array The settings for the breadcrumbs block.
+ *
+ * @internal
+ */
+ public function set_product_breadcrumbs_preferred_taxonomy( $settings, $post_type ) {
+ if ( ! is_array( $settings ) || 'product' !== $post_type ) {
+ return $settings;
+ }
+
+ $settings['taxonomy'] = 'product_cat';
+ return $settings;
+ }
}
diff --git a/plugins/woocommerce/tests/php/src/Internal/Orders/PaymentInfoTest.php b/plugins/woocommerce/tests/php/src/Internal/Orders/PaymentInfoTest.php
index d725a1f4fe..c51be1389d 100644
--- a/plugins/woocommerce/tests/php/src/Internal/Orders/PaymentInfoTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/Orders/PaymentInfoTest.php
@@ -57,7 +57,7 @@ class PaymentInfoTest extends WC_Unit_Test_Case {
);
$order->save();
- // Add a dummy callback to the filter. It should be prefered over metadata.
+ // Add a dummy callback to the filter. It should be preferred over metadata.
$filter_callback = fn() => array( 'payment_method' => 'foo' );
add_filter( 'wc_order_payment_card_info', $filter_callback );