Blockified Single Product Template: avoid to add another group block on the editor side when the user creates a template for a specific product (https://github.com/woocommerce/woocommerce-blocks/pull/9699)

* Blockified Single Product Template: avoid to add another group block on the editor side when the user creates a template for a specific product

* improve comment
This commit is contained in:
Luigi Teschio 2023-06-02 15:59:20 +02:00 committed by GitHub
parent 136762ee78
commit 278f0ec0db
1 changed files with 4 additions and 2 deletions

View File

@ -324,8 +324,10 @@ class BlockTemplatesController {
} }
if ( str_contains( $template->slug, 'single-product' ) ) { if ( str_contains( $template->slug, 'single-product' ) ) {
if ( ! is_admin() && ! BlockTemplateUtils::template_has_legacy_template_block( $template ) ) { // 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.
// More details: https://github.com/woocommerce/woocommerce-blocks/issues/9662.
if ( ( ! is_admin() && ! ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) && ! BlockTemplateUtils::template_has_legacy_template_block( $template ) ) {
$new_content = SingleProductTemplateCompatibility::add_compatibility_layer( $template->content ); $new_content = SingleProductTemplateCompatibility::add_compatibility_layer( $template->content );
$template->content = $new_content; $template->content = $new_content;
} }