WooCommerce Code Reference

WC_Tracker
in package

WooCommerce Tracker Class

Table of Contents

$api_url  : string
URL to the WooThemes Tracker API endpoint.
get_block_tracker_data()  : array
Get tracker data for a specific block type on a woocommerce page.
get_cart_checkout_info()  : array
Get info about the cart & checkout pages.
get_order_totals()  : array
Get order totals
get_product_counts()  : array
Get product totals based on product type.
get_theme_info()  : array
Get the current theme info, theme name and version.
init()  : mixed
Hook into cron event.
post_contains_text()  : string
Search a specific post for text content.
send_tracking_data()  : mixed
Decide whether to send tracking data or not.
get_active_payment_gateways()  : array
Get a list of all active payment gateways.
get_active_shipping_methods()  : array
Get a list of all active shipping methods.
get_admin_user_agents()  : array
When an admin user logs in, there user agent is tracked in user meta and collected here.
get_all_blocks_from_page()  : array
Get blocks from a woocommerce page.
get_all_plugins()  : array
Get all plugins grouped into activated or not.
get_all_template_overrides()  : array
Look for any template override and return filenames.
get_all_woocommerce_options_values()  : array
Get all options starting with woocommerce_ prefix.
get_blocks_from_page()  : array
Get all instances of the specified block on a specific woo page (e.g. `cart` or `checkout` page).
get_category_counts()  : int
Get the number of product categories.
get_helper_connected()  : string
Check to see if the helper is connected to woocommerce.com
get_last_send_time()  : int|bool
Get the last time tracking data was sent.
get_order_counts()  : array
Get order counts
get_order_dates()  : string
Get last order date
get_orders()  : array
Combine all order data.
get_review_counts()  : array
Get review counts for different statuses.
get_server_info()  : array
Get server related info.
get_tracking_data()  : array
Get all the tracking data.
get_user_counts()  : array
Get user totals based on user role.
get_wordpress_info()  : array
Get WordPress related data.
is_jetpack_staging_site()  : bool
Test whether this site is a staging site according to the Jetpack criteria.

Properties

$api_url

URL to the WooThemes Tracker API endpoint.

private static string $api_url = 'https://tracking.woocommerce.com/v1/'

Methods

get_block_tracker_data()

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

public static get_block_tracker_data(string $block_name, string $woo_page_name) : array
Parameters
$block_name : string

The name (id) of a block, e.g. woocommerce/cart.

$woo_page_name : string

The woo page to search, e.g. cart.

Return values
arrayAssociative array of tracker data with keys: - page_contains_block - block_attributes

get_cart_checkout_info()

Get info about the cart & checkout pages.

public static get_cart_checkout_info() : array
Return values
array

get_product_counts()

Get product totals based on product type.

public static get_product_counts() : array
Return values
array

get_theme_info()

Get the current theme info, theme name and version.

public static get_theme_info() : array
Return values
array

post_contains_text()

Search a specific post for text content.

public static post_contains_text(int $post_id, string $text) : string
Parameters
$post_id : int

The id of the post to search.

$text : string

The text to search for.

Return values
string'Yes' if post contains $text (otherwise 'No').

send_tracking_data()

Decide whether to send tracking data or not.

public static send_tracking_data([bool $override = false ]) : mixed
Parameters
$override : bool = false

Should override?.

Return values
mixed

get_active_payment_gateways()

Get a list of all active payment gateways.

private static get_active_payment_gateways() : array
Return values
array

get_active_shipping_methods()

Get a list of all active shipping methods.

private static get_active_shipping_methods() : array
Return values
array

get_admin_user_agents()

When an admin user logs in, there user agent is tracked in user meta and collected here.

private static get_admin_user_agents() : array
Return values
array

get_all_blocks_from_page()

Get blocks from a woocommerce page.

private static get_all_blocks_from_page(string $woo_page_name) : array
Parameters
$woo_page_name : string

A woocommerce page e.g. checkout or cart.

Return values
arrayArray of blocks as returned by parse_blocks().

get_all_plugins()

Get all plugins grouped into activated or not.

private static get_all_plugins() : array
Return values
array

get_all_template_overrides()

Look for any template override and return filenames.

private static get_all_template_overrides() : array
Return values
array

get_all_woocommerce_options_values()

Get all options starting with woocommerce_ prefix.

private static get_all_woocommerce_options_values() : array
Return values
array

get_blocks_from_page()

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

private static get_blocks_from_page(string $block_name, string $woo_page_name) : array
Parameters
$block_name : string

The name (id) of a block, e.g. woocommerce/cart.

$woo_page_name : string

The woo page to search, e.g. cart.

Return values
arrayArray of blocks as returned by parse_blocks().

get_category_counts()

Get the number of product categories.

private static get_category_counts() : int
Return values
int

get_helper_connected()

Check to see if the helper is connected to woocommerce.com

private static get_helper_connected() : string
Return values
string

get_last_send_time()

Get the last time tracking data was sent.

private static get_last_send_time() : int|bool
Return values
int|bool

get_review_counts()

Get review counts for different statuses.

private static get_review_counts() : array
Return values
array

get_tracking_data()

Get all the tracking data.

private static get_tracking_data() : array
Return values
array

get_user_counts()

Get user totals based on user role.

private static get_user_counts() : array
Return values
array

get_wordpress_info()

Get WordPress related data.

private static get_wordpress_info() : array
Return values
array

is_jetpack_staging_site()

Test whether this site is a staging site according to the Jetpack criteria.

private static is_jetpack_staging_site() : bool

With Jetpack 8.1+, Jetpack::is_staging_site has been deprecated. \Automattic\Jetpack\Status::is_staging_site is the replacement. However, there are version of JP where \Automattic\Jetpack\Status exists, but does not contain is_staging_site method, so with those, code still needs to use the previous check as a fallback.

Return values
bool