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

Commit f1d5d48

Browse files
authored
Single Product Template: fix Compatibility Layer when the template implements the Single Product Template (#9723)
1 parent 030fb5a commit f1d5d48

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/BlockTemplatesController.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -313,16 +313,6 @@ public function add_block_templates( $query_result, $query, $template_type ) {
313313
*/
314314
$query_result = array_map(
315315
function( $template ) {
316-
if ( 'theme' === $template->origin && BlockTemplateUtils::template_has_title( $template ) ) {
317-
return $template;
318-
}
319-
if ( $template->title === $template->slug ) {
320-
$template->title = BlockTemplateUtils::get_block_template_title( $template->slug );
321-
}
322-
if ( ! $template->description ) {
323-
$template->description = BlockTemplateUtils::get_block_template_description( $template->slug );
324-
}
325-
326316
if ( str_contains( $template->slug, 'single-product' ) ) {
327317
// We don't want to add the compatibility layer on the Editor Side.
328318
// 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 @@ function( $classes ) {
339329
$new_content = SingleProductTemplateCompatibility::add_compatibility_layer( $template->content );
340330
$template->content = $new_content;
341331
}
332+
}
333+
334+
if ( 'theme' === $template->origin && BlockTemplateUtils::template_has_title( $template ) ) {
342335
return $template;
343336
}
337+
if ( $template->title === $template->slug ) {
338+
$template->title = BlockTemplateUtils::get_block_template_title( $template->slug );
339+
}
340+
if ( ! $template->description ) {
341+
$template->description = BlockTemplateUtils::get_block_template_description( $template->slug );
342+
}
344343

345344
return $template;
346345
},

0 commit comments

Comments
 (0)