WooCommerce\Admin
Experimental_Abtest::in_treatment()
Returns true if the current user is in the treatment group of the given experiment.
Method of the class: Experimental_Abtest{}
No Hooks.
Returns
true|false
. True if the user is in the treatment group, false otherwise.
Usage
$result = Experimental_Abtest::in_treatment( $experiment_name, $as_auth_wpcom_user );
- $experiment_name(string) (required)
- Name of the experiment.
- $as_auth_wpcom_user(true|false)
- Request variation as a auth wp user or not.
Default: false
Experimental_Abtest::in_treatment() Experimental Abtest::in treatment code WC 9.8.5
public static function in_treatment( string $experiment_name, bool $as_auth_wpcom_user = false ) { $anon_id = isset( $_COOKIE['tk_ai'] ) ? sanitize_text_field( wp_unslash( $_COOKIE['tk_ai'] ) ) : ''; $allow_tracking = 'yes' === get_option( 'woocommerce_allow_tracking' ); $abtest = new self( $anon_id, 'woocommerce', $allow_tracking, $as_auth_wpcom_user ); return $abtest->get_variation( $experiment_name ) === 'treatment'; }