Automattic\WooCommerce\Admin\Features\OnboardingTasks

TaskLists::is_experiment_treatment()public staticWC 1.0

Check if an experiment is the treatment or control.

{} It's a method of the class: TaskLists{}

No Hooks.

Return

true|false.

Usage

$result = TaskLists::is_experiment_treatment( $name );
$name(string) (required)
Name prefix of experiment.

Code of TaskLists::is_experiment_treatment() WC 6.8.2

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';
}