WooCommerce\Admin
Experimental_Abtest::get_variation
Retrieve the test variation for a provided A/B test.
Метод класса: Experimental_Abtest{}
Хуков нет.
Возвращает
Разное|null. A/B test variation, or null on failure.
Использование
$Experimental_Abtest = new Experimental_Abtest(); $Experimental_Abtest->get_variation( $test_name );
- $test_name(строка) (обязательный)
- Name of the A/B test.
Код Experimental_Abtest::get_variation() Experimental Abtest::get variation WC 10.4.0
public function get_variation( $test_name ) {
// Default to the control variation when users haven't consented to tracking.
if ( ! $this->consent ) {
return 'control';
}
$variation = $this->fetch_variation( $test_name );
// If there was an error retrieving a variation, conceal the error for the consumer.
// If there was an error retrieving a variation, throw an exception in non-production environments.
if ( is_wp_error( $variation ) ) {
if ( 'production' !== wp_get_environment_type() ) {
throw new \Exception( $variation->get_error_message() );
}
return 'control';
}
return $variation;
}