WC_Blocks_Utils::get_blocks_from_page()public staticWC 1.0

Get all instances of the specified block on a specific woo page (e.g. cart or checkout page).

{} Это метод класса: WC_Blocks_Utils{}

Хуков нет.


Массив. Array of blocks as returned by parse_blocks().


$result = WC_Blocks_Utils::get_blocks_from_page( $block_name, $woo_page_name );
$block_name(строка) (обязательный)
The name (id) of a block, e.g. woocommerce/cart.
$woo_page_name(строка) (обязательный)
The woo page to search, e.g. cart.

Код WC_Blocks_Utils::get_blocks_from_page() WC 6.9.4

public static function get_blocks_from_page( $block_name, $woo_page_name ) {
	$page_blocks = self::get_all_blocks_from_page( $woo_page_name );

	// Get any instances of the specified block.
	return array_values(
			function ( $block ) use ( $block_name ) {
				return ( $block_name === $block['blockName'] );