WordPress at Your Fingertips
function is not described


Experimental_Abtest::get_variation() public WC 1.0

Retrieve the test variation for a provided A/B test.

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

No Hooks.


Mixed|null. A/B test variation, or null on failure.


$Experimental_Abtest = new Experimental_Abtest();
$Experimental_Abtest->get_variation( $test_name );
$test_name(string) (required)
Name of the A/B test.

Code of Experimental_Abtest::get_variation() WC 6.1.1

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 ( is_wp_error( $variation ) ) {
		return 'control';

	return $variation;