WooCommerce Code Reference

WC_Products_Tracking
in package

This class adds actions to track usage of WooCommerce Products.

Table of Contents

init()  : mixed
Init tracking.
possibly_add_attribute_tracking_scripts()  : mixed
Adds the tracking scripts for product attributes filtering actions.
possibly_add_product_import_scripts()  : mixed
Adds the tracking scripts for product setting pages.
possibly_add_product_tracking_scripts()  : mixed
Adds the tracking scripts for product filtering actions.
possibly_add_tag_tracking_scripts()  : mixed
Adds the tracking scripts for tags and categories filtering actions.
track_categories_and_tags_view()  : mixed
Send a Tracks event when the Products Categories and Tags page is viewed.
track_product_category_created()  : mixed
Send a Tracks event when a product category is created.
track_product_category_updated()  : mixed
Send a Tracks event when a product category is updated.
track_product_published()  : mixed
Send a Tracks event when a product is published.
track_product_updated()  : mixed
Send a Tracks event when a product is updated.
track_product_updated_client_side()  : mixed
Track the Update button being clicked on the client side.
track_products_view()  : mixed
Send a Tracks event when the Products page is viewed.
get_product_screen()  : string|bool
Adds the tracking scripts for product filtering actions.
get_possible_product_type_options_ids()  : array<string|int, mixed>
Get the IDs of the possible product type options.
get_product_type_options()  : array<string|int, mixed>
Get the product type options for a product.
get_product_type_options_string()  : string
Get a comma-separated string of the product type options that are enabled.

Methods

possibly_add_attribute_tracking_scripts()

Adds the tracking scripts for product attributes filtering actions.

public possibly_add_attribute_tracking_scripts(string $hook) : mixed
Parameters
$hook : string

Page hook.

Return values
mixed

possibly_add_product_import_scripts()

Adds the tracking scripts for product setting pages.

public possibly_add_product_import_scripts(string $hook) : mixed
Parameters
$hook : string

Page hook.

Return values
mixed

possibly_add_product_tracking_scripts()

Adds the tracking scripts for product filtering actions.

public possibly_add_product_tracking_scripts(string $hook) : mixed
Parameters
$hook : string

Page hook.

Return values
mixed

possibly_add_tag_tracking_scripts()

Adds the tracking scripts for tags and categories filtering actions.

public possibly_add_tag_tracking_scripts(string $hook) : mixed
Parameters
$hook : string

Page hook.

Return values
mixed

track_product_category_created()

Send a Tracks event when a product category is created.

public track_product_category_created(int $category_id) : mixed
Parameters
$category_id : int

Category ID.

Return values
mixed

track_product_category_updated()

Send a Tracks event when a product category is updated.

public track_product_category_updated(int $category_id) : mixed
Parameters
$category_id : int

Category ID.

Return values
mixed

track_product_published()

Send a Tracks event when a product is published.

public track_product_published(int $post_id, WP_Post $post, bool $update, null|WP_Post $post_before) : mixed
Parameters
$post_id : int

Post ID.

$post : WP_Post

Post object.

$update : bool

Whether this is an existing post being updated.

$post_before : null|WP_Post

Null for new posts, the WP_Post object prior to the update for updated posts.

Return values
mixed

track_product_updated()

Send a Tracks event when a product is updated.

public track_product_updated(int $product_id, object $post) : mixed
Parameters
$product_id : int

Product id.

$post : object

WordPress post.

Return values
mixed

track_product_updated_client_side()

Track the Update button being clicked on the client side.

public track_product_updated_client_side(WP_Post $post) : mixed

This is needed because track_product_updated (using the edit_post hook) is called in response to a number of other triggers.

Parameters
$post : WP_Post

The post, not used.

Return values
mixed

get_product_screen()

Adds the tracking scripts for product filtering actions.

protected get_product_screen(string $hook) : string|bool
Parameters
$hook : string

Hook of the current page.

Return values
string|bool

get_possible_product_type_options_ids()

Get the IDs of the possible product type options.

private static get_possible_product_type_options_ids() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_product_type_options()

Get the product type options for a product.

private static get_product_type_options(int $post_id) : array<string|int, mixed>
Parameters
$post_id : int

The ID of the product.

Return values
array<string|int, mixed>

get_product_type_options_string()

Get a comma-separated string of the product type options that are enabled.

private static get_product_type_options_string(array<string|int, mixed> $product_type_options) : string
Parameters
$product_type_options : array<string|int, mixed>

The product type options.

Return values
string