WC_Tracker::get_block_tracker_data()
Get tracker data for a specific block type on a woocommerce page.
Метод класса: WC_Tracker{}
Хуков нет.
Возвращает
Массив
. Associative array of tracker data with keys:
- page_contains_block
- block_attributes
Использование
$result = WC_Tracker::get_block_tracker_data( $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_Tracker::get_block_tracker_data() WC Tracker::get block tracker data WC 8.1.1
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, ); }