Automattic\WooCommerce\Blocks\Utils
CartCheckoutUtils::is_overriden_by_custom_template_content()
Checks if the template overriding the page loads the page content or not. Templates by default load the page content, but if that block is deleted the content can get out of sync with the one presented in the page editor.
Method of the class: CartCheckoutUtils{}
No Hooks.
Return
true|false
. true if the template has out of sync content.
Usage
$result = CartCheckoutUtils::is_overriden_by_custom_template_content( $block ): bool;
- $block(string) (required)
- The block to check.
CartCheckoutUtils::is_overriden_by_custom_template_content() CartCheckoutUtils::is overriden by custom template content code WC 9.4.2
public static function is_overriden_by_custom_template_content( string $block ): bool { $block = str_replace( 'woocommerce/', '', $block ); if ( wc_current_theme_is_fse_theme() ) { $templates_from_db = BlockTemplateUtils::get_block_templates_from_db( array( 'page-' . $block ) ); foreach ( $templates_from_db as $template ) { if ( ! has_block( 'woocommerce/page-content-wrapper', $template->content ) ) { // Return true if the template does not load the page content via the woocommerce/page-content-wrapper block. return true; } } } return false; }