Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 873caab

Browse files
authored
Display correct block template when filtering by attribute (#7640)
1 parent 5b239c3 commit 873caab

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/BlockTemplatesController.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,17 +426,21 @@ public function render_block_template() {
426426
$this->block_template_is_available( 'taxonomy-product_tag' )
427427
) {
428428
add_filter( 'woocommerce_has_block_template', '__return_true', 10, 0 );
429-
} elseif ( taxonomy_is_product_attribute( get_query_var( 'taxonomy' ) ) &&
430-
! BlockTemplateUtils::theme_has_template( 'archive-product' ) &&
431-
$this->block_template_is_available( 'archive-product' )
432-
) {
433-
add_filter( 'woocommerce_has_block_template', '__return_true', 10, 0 );
434429
} elseif (
435430
( is_post_type_archive( 'product' ) || is_page( wc_get_page_id( 'shop' ) ) ) &&
436431
! BlockTemplateUtils::theme_has_template( 'archive-product' ) &&
437432
$this->block_template_is_available( 'archive-product' )
438433
) {
439434
add_filter( 'woocommerce_has_block_template', '__return_true', 10, 0 );
435+
} else {
436+
$queried_object = get_queried_object();
437+
438+
if ( taxonomy_is_product_attribute( $queried_object->slug ) &&
439+
! BlockTemplateUtils::theme_has_template( 'archive-product' ) &&
440+
$this->block_template_is_available( 'archive-product' )
441+
) {
442+
add_filter( 'woocommerce_has_block_template', '__return_true', 10, 0 );
443+
}
440444
}
441445
}
442446

src/Templates/ProductAttributeTemplate.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ protected function init() {
3030
* @param array $templates Templates that match the product attributes taxonomy.
3131
*/
3232
public function update_taxonomy_template_hierarchy( $templates ) {
33-
if ( taxonomy_is_product_attribute( get_query_var( 'taxonomy' ) ) && wc_current_theme_is_fse_theme() ) {
33+
$queried_object = get_queried_object();
34+
if ( taxonomy_is_product_attribute( $queried_object->slug ) && wc_current_theme_is_fse_theme() ) {
3435
array_unshift( $templates, self::SLUG );
3536
}
3637

0 commit comments

Comments
 (0)