WooCommerce\Admin
Experimental_Abtest::get_variation()
Retrieve the test variation for a provided A/B test.
Method of the class: Experimental_Abtest{}
No Hooks.
Return
Mixed|null
. A/B test variation, or null on failure.
Usage
$Experimental_Abtest = new Experimental_Abtest(); $Experimental_Abtest->get_variation( $test_name );
- $test_name(string) (required)
- Name of the A/B test.
Experimental_Abtest::get_variation() Experimental Abtest::get variation code WC 9.4.2
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; }