Wrap product spotlight tour under ExPlat logic (#33361)

* Add experiment wrap

* Changelog

* Move experiment check to bottom to minimize explat calls
This commit is contained in:
Ilyas Foo 2022-06-09 16:21:28 +08:00 committed by GitHub
parent fe267f355e
commit e3744709c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: add
Wrap spotlight product tour under experiment logic

View File

@ -42,6 +42,22 @@ class WC_Admin_Pointers {
}
}
/**
* Check if product tour experiment is treatment.
*
* @return bool
*/
public static function is_experiment_product_tour() {
$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
);
return $abtest->get_variation( 'woocommerce_products_tour' ) === 'treatment';
}
/**
* Pointers for creating a product.
*/
@ -55,7 +71,8 @@ class WC_Admin_Pointers {
if (
Features::is_enabled( 'experimental-product-tour' ) &&
isset( $_GET['spotlight'] ) && // phpcs:ignore WordPress.Security.NonceVerification.Recommended
isset( $wp_post_types )
isset( $wp_post_types ) &&
self::is_experiment_product_tour()
) {
$labels = $wp_post_types['product']->labels;
$labels->add_new = __( 'Enable guided mode', 'woocommerce' );