From eddaf349183e69aee82cd9eac8da098c66336c4f Mon Sep 17 00:00:00 2001 From: Luigi Teschio Date: Mon, 5 Jun 2023 17:48:36 +0200 Subject: [PATCH] Single Product Template: fix Compatibility Layer when the template implements the Single Product Template (https://github.com/woocommerce/woocommerce-blocks/pull/9723) --- .../src/BlockTemplatesController.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/plugins/woocommerce-blocks/src/BlockTemplatesController.php b/plugins/woocommerce-blocks/src/BlockTemplatesController.php index 4b90430d393..4ec11011760 100644 --- a/plugins/woocommerce-blocks/src/BlockTemplatesController.php +++ b/plugins/woocommerce-blocks/src/BlockTemplatesController.php @@ -313,16 +313,6 @@ class BlockTemplatesController { */ $query_result = array_map( function( $template ) { - if ( 'theme' === $template->origin && BlockTemplateUtils::template_has_title( $template ) ) { - return $template; - } - if ( $template->title === $template->slug ) { - $template->title = BlockTemplateUtils::get_block_template_title( $template->slug ); - } - if ( ! $template->description ) { - $template->description = BlockTemplateUtils::get_block_template_description( $template->slug ); - } - if ( str_contains( $template->slug, 'single-product' ) ) { // We don't want to add the compatibility layer on the Editor Side. // The second condition is necessary to not apply the compatibility layer on the REST API. Gutenberg uses the REST API to clone the template. @@ -339,8 +329,17 @@ class BlockTemplatesController { $new_content = SingleProductTemplateCompatibility::add_compatibility_layer( $template->content ); $template->content = $new_content; } + } + + if ( 'theme' === $template->origin && BlockTemplateUtils::template_has_title( $template ) ) { return $template; } + if ( $template->title === $template->slug ) { + $template->title = BlockTemplateUtils::get_block_template_title( $template->slug ); + } + if ( ! $template->description ) { + $template->description = BlockTemplateUtils::get_block_template_description( $template->slug ); + } return $template; },