WooCommerce Code Reference

WC_Product_Collection_Block_Tracking
in package

This class adds actions to track usage of the Product Collection Block.

Table of Contents

init()  : mixed
Init Tracking.
track_collection_instances()  : void
Track feature usage of the Product Collection block within the site editor.
get_query_filters_usage_data()  : array<string|int, mixed>
Parse the collection query filters from the query attributes.
parse_blocks_track_data()  : array<string|int, mixed>
Track usage of the Product Collection block within the given blocks.
parse_editor_location_context()  : string
Parse editor's location context from WP Post.

Methods

track_collection_instances()

Track feature usage of the Product Collection block within the site editor.

public track_collection_instances(int $post_id, WP_Post $post) : void
Parameters
$post_id : int

The post ID.

$post : WP_Post

The post object.

Return values
void

get_query_filters_usage_data()

Parse the collection query filters from the query attributes.

private get_query_filters_usage_data(array<string|int, mixed> $block) : array<string|int, mixed>
Parameters
$block : array<string|int, mixed>

The parsed block.

Return values
array<string|int, mixed>The filters data for tracking.

parse_blocks_track_data()

Track usage of the Product Collection block within the given blocks.

private parse_blocks_track_data(array<string|int, mixed> $blocks[, bool $is_in_single_product = false ][, bool $is_in_template_part = false ][, bool $is_in_synced_pattern = false ]) : array<string|int, mixed>
Parameters
$blocks : array<string|int, mixed>

The parsed blocks to check.

$is_in_single_product : bool = false

Whether we are in a single product container (used for keeping state in the recurring process).

$is_in_template_part : bool = false

Whether we are in a template part (used for keeping state in the recurring process).

$is_in_synced_pattern : bool = false

Whether we are in a synced block (used for keeping state in the recurring process).

Return values
array<string|int, mixed>Parsed instances of the Product Collection block.

parse_editor_location_context()

Parse editor's location context from WP Post.

private parse_editor_location_context(WP_Post $post) : string

Possible contexts:

  • post
  • page
  • single-product
  • product-archive
  • cart
  • checkout
  • product-catalog
  • order-confirmation
Parameters
$post : WP_Post

The Post instance.

Return values
stringReturns the context.