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<string|int, mixed>
Get tracker data for a specific block type on a woocommerce page.
get_cart_checkout_info()  : array<string|int, mixed>
Get info about the cart & checkout pages.
get_checkout_additional_fields_data()  : array<string|int, mixed>
Get tracker data for additional fields on the checkout page.
get_pickup_location_data()  : array<string|int, mixed>
Get tracker data for a pickup location method.
get_product_counts()  : array<string|int, mixed>
Get product totals based on product type.
get_theme_info()  : array<string|int, mixed>
Get the current theme info, theme name and version.
get_tracking_data()  : array<string|int, mixed>
Get all the tracking data.
get_woocommerce_mobile_usage()  : array<string|int, mixed>
Get info about WooCommerce Mobile App usage
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.
extract_group_key()  : array<string|int, mixed>
Extract the group key for an associative array of objects which have unique ids in the key.
get_active_payment_gateways()  : array<string|int, mixed>
Get a list of all active payment gateways.
get_active_shipping_methods()  : array<string|int, mixed>
Get a list of all active shipping methods.
get_all_plugins()  : array<string|int, mixed>
Get all plugins grouped into activated or not.
get_all_template_overrides()  : array<string|int, mixed>
Look for any template override and return filenames.
get_all_woocommerce_options_values()  : array<string|int, mixed>
Get all options starting with woocommerce_ prefix.
get_category_counts()  : int
Get the number of product categories.
get_enabled_features()  : array<string|int, string>
Get an array of slugs for WC features that are enabled on the site.
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_mini_cart_info()  : array<string|int, mixed>
Get info about the Mini Cart Block.
get_order_counts()  : array<string|int, mixed>
Get order counts.
get_order_dates()  : string
Get last order date.
get_order_totals()  : array<string|int, mixed>
Get order totals.
get_orders()  : array<string|int, mixed>
Combine all order data.
get_orders_by_gateway()  : array<string|int, mixed>
Get order details by gateway.
get_orders_origins()  : array<string|int, mixed>
Get orders origin details.
get_review_counts()  : array<string|int, mixed>
Get review counts for different statuses.
get_server_info()  : array<string|int, mixed>
Get server related info.
get_user_counts()  : array<string|int, mixed>
Get user totals based on user role.
get_wcpay_settings()  : array<string|int, mixed>
Get the settings of WooCommerce Payments plugin
get_wordpress_info()  : array<string|int, mixed>
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<string|int, mixed>
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
array<string|int, mixed>Associative 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<string|int, mixed>
Return values
array<string|int, mixed>

get_checkout_additional_fields_data()

Get tracker data for additional fields on the checkout page.

public static get_checkout_additional_fields_data() : array<string|int, mixed>
Return values
array<string|int, mixed>Array of fields count and names.

get_pickup_location_data()

Get tracker data for a pickup location method.

public static get_pickup_location_data() : array<string|int, mixed>
Return values
array<string|int, mixed>Associative array of tracker data with keys: - pickup_location_enabled - pickup_locations_count

get_product_counts()

Get product totals based on product type.

public static get_product_counts() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_theme_info()

Get the current theme info, theme name and version.

public static get_theme_info() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_tracking_data()

Get all the tracking data.

public static get_tracking_data() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_woocommerce_mobile_usage()

Get info about WooCommerce Mobile App usage

public static get_woocommerce_mobile_usage() : array<string|int, mixed>
Return values
array<string|int, mixed>

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

extract_group_key()

Extract the group key for an associative array of objects which have unique ids in the key.

private static extract_group_key(array<string|int, mixed> $objects, string $default_key) : array<string|int, mixed>

A 'group_key' property is introduced in the object. For example, two objects with keys like 'WooDataPay ** #123' and 'WooDataPay ** #78' would both have a group_key of 'WooDataPay **' after this function call.

Parameters
$objects : array<string|int, mixed>

The array of objects that need to be grouped.

$default_key : string

The property that will be the default group_key.

Return values
array<string|int, mixed>Contains the objects with a group_key property.

get_active_payment_gateways()

Get a list of all active payment gateways.

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

get_active_shipping_methods()

Get a list of all active shipping methods.

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

get_all_plugins()

Get all plugins grouped into activated or not.

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

get_all_template_overrides()

Look for any template override and return filenames.

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

get_all_woocommerce_options_values()

Get all options starting with woocommerce_ prefix.

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

get_category_counts()

Get the number of product categories.

private static get_category_counts() : int
Return values
int

get_enabled_features()

Get an array of slugs for WC features that are enabled on the site.

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

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_mini_cart_info()

Get info about the Mini Cart Block.

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

get_order_counts()

Get order counts.

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

get_order_totals()

Get order totals.

private static get_order_totals() : array<string|int, mixed>
Tags
since
5.4.0
Return values
array<string|int, mixed>

get_orders()

Combine all order data.

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

get_orders_by_gateway()

Get order details by gateway.

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

get_orders_origins()

Get orders origin details.

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

get_review_counts()

Get review counts for different statuses.

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

get_server_info()

Get server related info.

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

get_user_counts()

Get user totals based on user role.

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

get_wcpay_settings()

Get the settings of WooCommerce Payments plugin

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

get_wordpress_info()

Get WordPress related data.

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

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