Automattic\WooCommerce\Admin\Features\OnboardingTasks

TaskLists::is_experiment_treatment()public staticWC 1.0

Check if an experiment is the treatment or control.

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

Хуков нет.

Возвращает

true|false.

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

$result = TaskLists::is_experiment_treatment( $name );
$name(строка) (обязательный)
Name prefix of experiment.

Код TaskLists::is_experiment_treatment() WC 6.6.1

public static function is_experiment_treatment( $name ) {
	$anon_id        = isset( $_COOKIE['tk_ai'] ) ? sanitize_text_field( wp_unslash( $_COOKIE['tk_ai'] ) ) : '';
	$allow_tracking = 'yes' === get_option( 'woocommerce_allow_tracking' );
	$abtest         = new \WooCommerce\Admin\Experimental_Abtest(
		$anon_id,
		'woocommerce',
		$allow_tracking
	);

	$date = new \DateTime();
	$date->setTimeZone( new \DateTimeZone( 'UTC' ) );

	$experiment_name = sprintf(
		'%s_%s_%s',
		$name,
		$date->format( 'Y' ),
		$date->format( 'm' )
	);
	return $abtest->get_variation( $experiment_name ) === 'treatment';
}