Automattic\WooCommerce\Blocks\Templates
SingleProductTemplateCompatibility::has_single_product_template_blocks
Check if the Single Product template has a single product template block: woocommerce/product-gallery-image, woocommerce/product-details, woocommerce/add-to-cart-form, etc.
Method of the class: SingleProductTemplateCompatibility{}
No Hooks.
Returns
true|false. True if the template has a single product template block, false otherwise.
Usage
$result = SingleProductTemplateCompatibility::has_single_product_template_blocks( $parsed_blocks );
- $parsed_blocks(array) (required)
- Array of parsed block objects.
SingleProductTemplateCompatibility::has_single_product_template_blocks() SingleProductTemplateCompatibility::has single product template blocks code WC 10.5.0
private static function has_single_product_template_blocks( $parsed_blocks ) {
$single_product_template_blocks = array( 'woocommerce/product-image-gallery', 'woocommerce/product-gallery', 'woocommerce/product-details', 'woocommerce/add-to-cart-form', 'woocommerce/add-to-cart-with-options', 'woocommerce/product-meta', 'woocommerce/product-price', 'woocommerce/breadcrumbs' );
return BlockTemplateUtils::has_block_including_patterns( $single_product_template_blocks, $parsed_blocks );
}