Add backend experiment logic
This commit is contained in:
parent
16c36e1f7d
commit
481b1e8566
|
@ -340,7 +340,10 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
|
|||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public static function import_sample_products() {
|
||||
if ( Features::is_enabled( 'experimental-products-task' ) || Features::is_enabled( 'experimental-import-products-task' ) ) {
|
||||
if (
|
||||
( Features::is_enabled( 'experimental-import-products-task' ) || Features::is_enabled( 'experimental-products-task' ) )
|
||||
&& static::is_experiment_product_task()
|
||||
) {
|
||||
$sample_csv_file = WC_ABSPATH . 'sample-data/experimental_sample_9_products.csv';
|
||||
} else {
|
||||
$sample_csv_file = WC_ABSPATH . 'sample-data/sample_products.csv';
|
||||
|
@ -350,6 +353,22 @@ class OnboardingTasks extends \WC_REST_Data_Controller {
|
|||
return rest_ensure_response( $import );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if product task experiment is treatment.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_experiment_product_task() {
|
||||
$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_task_layout_stacked' ) === 'treatment' ||
|
||||
$abtest->get_variation( 'woocommerce_products_task_layout_card' ) === 'treatment';
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a product from a template name passed in through the template_name param.
|
||||
|
|
Loading…
Reference in New Issue