WooCommerce Code Reference

Search results

WC_Tracker

WooCommerce Tracker Class

Table of Contents

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

Properties

$api_url

URL to the WooThemes Tracker API endpoint.

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

Methods

init()

Hook into cron event.

public static init( ) : mixed
Return values
mixed

send_tracking_data()

Decide whether to send tracking data or not.

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

Should override?.

Return values
mixed

get_last_send_time()

Get the last time tracking data was sent.

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

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

get_tracking_data()

Get all the tracking data.

private static get_tracking_data( ) : 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

get_wordpress_info()

Get WordPress related data.

private static get_wordpress_info( ) : array
Return values
array

get_server_info()

Get server related info.

private static get_server_info( ) : array
Return values
array

get_all_plugins()

Get all plugins grouped into activated or not.

private static get_all_plugins( ) : array
Return values
array

get_helper_connected()

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

private static get_helper_connected( ) : string
Return values
string

get_user_counts()

Get user totals based on user role.

private static get_user_counts( ) : array
Return values
array

get_product_counts()

Get product totals based on product type.

public static get_product_counts( ) : array
Return values
array

get_order_counts()

Get order counts

private static get_order_counts( ) : array
Return values
array

get_orders()

Combine all order data.

private static get_orders( ) : array
Return values
array

get_review_counts()

Get review counts for different statuses.

private static get_review_counts( ) : array
Return values
array

get_category_counts()

Get the number of product categories.

private static get_category_counts( ) : int
Return values
int

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

Get all options starting with woocommerce_ prefix.

private static get_all_woocommerce_options_values( ) : 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_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_order_totals()

Get order totals

public static get_order_totals( ) : array
Return values
array

get_order_dates()

Get last order date

private static get_order_dates( ) : string
Return values
string

post_contains_text()

Search a specific post for text content.

public static post_contains_text( $post_id : int , $text : string ) : 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').

get_all_blocks_from_page()

Get blocks from a woocommerce page.

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

A woocommerce page e.g. checkout or cart.

Return values
array

Array of blocks as returned by parse_blocks().

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( $block_name : string , $woo_page_name : string ) : 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
array

Array of blocks as returned by parse_blocks().

get_block_tracker_data()

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

public static get_block_tracker_data( $block_name : string , $woo_page_name : string ) : 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
array

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
Return values
array
Back to the top