Automattic\WooCommerce\Admin\Features\OnboardingTasks
TaskLists::is_experiment_treatment()
Check if an experiment is the treatment or control.
Method of the class: TaskLists{}
No Hooks.
Return
true|false
.
Usage
$result = TaskLists::is_experiment_treatment( $name );
- $name(string) (required)
- Name prefix of experiment.
TaskLists::is_experiment_treatment() TaskLists::is experiment treatment code WC 9.7.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'; }