WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_Tracks_Client::maybe_set_identity_cookie() public WC 1.0

Check if identiy cookie is set, if not set it.

Это метод класса: WC_Tracks_Client{}

Хуков нет.

Возвращает

null.

Использование

$result = WC_Tracks_Client::maybe_set_identity_cookie();

Код WC_Tracks_Client::maybe_set_identity_cookie() WC 4.5.2

woocommerce/includes/tracks/class-wc-tracks-client.php
<?php
public static function maybe_set_identity_cookie() {
	// Do not set on AJAX requests.
	if ( Constants::is_true( 'DOING_AJAX' ) ) {
		return;
	}

	// Bail if cookie already set.
	if ( isset( $_COOKIE['tk_ai'] ) ) {
		return;
	}

	$user = wp_get_current_user();

	// We don't want to track user events during unit tests/CI runs.
	if ( $user instanceof WP_User && 'wptests_capabilities' === $user->cap_key ) {
		return false;
	}
	$user_id = $user->ID;
	$anon_id = get_user_meta( $user_id, '_woocommerce_tracks_anon_id', true );

	// If an id is still not found, create one and save it.
	if ( ! $anon_id ) {
		$anon_id = self::get_anon_id();
		update_user_meta( $user_id, '_woocommerce_tracks_anon_id', $anon_id );
	}

	// Don't set cookie on API requests.
	if ( ! Constants::is_true( 'REST_REQUEST' ) && ! Constants::is_true( 'XMLRPC_REQUEST' ) ) {
		wc_setcookie( 'tk_ai', $anon_id );
	}
}