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]
Метод класса: SingleProductTemplateCompatibility{}
Хуков нет.
Возвращает
true|false
. True if the template has a single product template block, false otherwise.
Использование
$result = SingleProductTemplateCompatibility::has_single_product_template_blocks( $parsed_blocks );
- $parsed_blocks(массив) (обязательный)
- Array of parsed block objects.
Код SingleProductTemplateCompatibility::has_single_product_template_blocks() SingleProductTemplateCompatibility::has single product template blocks WC 9.2.3
private static function has_single_product_template_blocks( $parsed_blocks ) { $single_product_template_blocks = array( 'woocommerce/product-image-gallery', 'woocommerce/product-details', 'woocommerce/add-to-cart-form', 'woocommerce/product-meta', 'woocommerce/product-price', 'woocommerce/breadcrumbs' ); $found = false; foreach ( $parsed_blocks as $block ) { if ( isset( $block['blockName'] ) && in_array( $block['blockName'], $single_product_template_blocks, true ) ) { $found = true; break; } $found = self::has_single_product_template_blocks( $block['innerBlocks'], $single_product_template_blocks ); if ( $found ) { break; } } return $found; }