WordPress at Your Fingertips
function is not described

WC_Blocks_Utils::get_blocks_from_page() public WC 1.0

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

{} It's a method of the class: WC_Blocks_Utils{}

No Hooks.


Array. Array of blocks as returned by parse_blocks().


$result = WC_Blocks_Utils::get_blocks_from_page( $block_name, $woo_page_name );
$block_name(string) (required)
The name (id) of a block, e.g. woocommerce/cart.
$woo_page_name(string) (required)
The woo page to search, e.g. cart.

Code of WC_Blocks_Utils::get_blocks_from_page() WC 5.6.0

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'] );