Add Experimental_Abtest usage
This commit is contained in:
parent
4e0faa6ea1
commit
aaf9282277
|
@ -24,6 +24,18 @@ use Automattic\Jetpack\Connection\Client as Jetpack_Connection_client;
|
||||||
/**
|
/**
|
||||||
* This class provides an interface to the Explat A/B tests.
|
* This class provides an interface to the Explat A/B tests.
|
||||||
*
|
*
|
||||||
|
* Usage:
|
||||||
|
*
|
||||||
|
* $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
|
||||||
|
* );
|
||||||
|
*
|
||||||
|
* $isTreatment = $abtest->get_variation('your-experiment-name') === 'treatment';
|
||||||
|
*
|
||||||
* @internal This class is experimental and should not be used externally due to planned breaking changes.
|
* @internal This class is experimental and should not be used externally due to planned breaking changes.
|
||||||
*/
|
*/
|
||||||
final class Experimental_Abtest {
|
final class Experimental_Abtest {
|
||||||
|
@ -176,6 +188,11 @@ final class Experimental_Abtest {
|
||||||
'anon_id' => rawurlencode( $this->anon_id ),
|
'anon_id' => rawurlencode( $this->anon_id ),
|
||||||
'woo_country_code' => rawurlencode( get_option( 'woocommerce_default_country', 'US:CA' ) ),
|
'woo_country_code' => rawurlencode( get_option( 'woocommerce_default_country', 'US:CA' ) ),
|
||||||
);
|
);
|
||||||
|
/**
|
||||||
|
* Get additional request args.
|
||||||
|
*
|
||||||
|
* @since 6.5.0
|
||||||
|
*/
|
||||||
$args = apply_filters( 'woocommerce_explat_request_args', $args );
|
$args = apply_filters( 'woocommerce_explat_request_args', $args );
|
||||||
$response = $this->request_assignment( $args );
|
$response = $this->request_assignment( $args );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue