WordPress at Your Fingertips
function is not described

WC_Tracker::get_block_tracker_data() public WC 1.0

Get tracker data for a specific block type on a woocommerce page.

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

No Hooks.

Return

Array. Associative array of tracker data with keys:

  • page_contains_block
  • block_attributes

Usage

$result = WC_Tracker::get_block_tracker_data( $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_Tracker::get_block_tracker_data() WC 5.9.0

public static function get_block_tracker_data( $block_name, $woo_page_name ) {
	$blocks = WC_Blocks_Utils::get_blocks_from_page( $block_name, $woo_page_name );

	$block_present = false;
	$attributes    = array();
	if ( $blocks && count( $blocks ) ) {
		// Return any customised attributes from the first block.
		$block_present = true;
		$attributes    = $blocks[0]['attrs'];
	}

	return array(
		'page_contains_block' => $block_present ? 'Yes' : 'No',
		'block_attributes'    => $attributes,
	);
}