WooCommerce::add_woocommerce_tracker_send_event_wrapperpublicWC 1.0

Wrapper for the woocommerce_tracker_send_event This prevents the event failing when the class is not loaded. It loads the class if it exists, and then calls the actual action.

Method of the class: WooCommerce{}

Hooks from the method

Returns

null. Nothing (null).

Usage

$WooCommerce = new WooCommerce();
$WooCommerce->add_woocommerce_tracker_send_event_wrapper();

WooCommerce::add_woocommerce_tracker_send_event_wrapper() code WC 10.7.0

public function add_woocommerce_tracker_send_event_wrapper() {
	if ( true !== wc_string_to_bool( get_option( 'woocommerce_allow_tracking', 'no' ) ) ) {
		return;
	}
	try {
		include_once WC_ABSPATH . 'includes/class-wc-tracker.php';
		if ( class_exists( WC_Tracker::class ) ) {
			WC_Tracker::init();
		}
	} catch ( Throwable $e ) {
		wc_get_logger()->error( 'Error initializing WC_Tracker: ' . $e->getMessage(), array( 'source' => 'woocommerce-scheduled-actions' ) );
	}
	// phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment
	do_action( 'woocommerce_tracker_send_event' );
}