diff --git a/plugins/woocommerce/changelog/add-33162-experiment-logic b/plugins/woocommerce/changelog/add-33162-experiment-logic new file mode 100644 index 00000000000..00d13cf4579 --- /dev/null +++ b/plugins/woocommerce/changelog/add-33162-experiment-logic @@ -0,0 +1,4 @@ +Significance: minor +Type: add + +Wrap spotlight product tour under experiment logic diff --git a/plugins/woocommerce/includes/admin/class-wc-admin-pointers.php b/plugins/woocommerce/includes/admin/class-wc-admin-pointers.php index 2fb2bc3f8ed..b04e1abe6ca 100644 --- a/plugins/woocommerce/includes/admin/class-wc-admin-pointers.php +++ b/plugins/woocommerce/includes/admin/class-wc-admin-pointers.php @@ -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' );