Redirect to new product experience when in experiment group (#36381)

* Redirect to new product experience when in experiment group

* Add changelog entry
This commit is contained in:
Joshua T Flowers 2023-01-12 11:02:40 -08:00 committed by GitHub
parent ad59769f25
commit 891ecb7efb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -4,6 +4,9 @@
import { useDispatch } from '@wordpress/data';
import { ITEMS_STORE_NAME } from '@woocommerce/data';
import { getAdminLink } from '@woocommerce/settings';
import { getNewPath, navigateTo } from '@woocommerce/navigation';
import { loadExperimentAssignment } from '@woocommerce/explat';
import moment from 'moment';
import { useState } from '@wordpress/element';
/**
@ -25,6 +28,21 @@ export const useCreateProductByType = () => {
}
setIsRequesting( true );
if ( type === 'physical' ) {
const momentDate = moment().utc();
const year = momentDate.format( 'YYYY' );
const month = momentDate.format( 'MM' );
const assignment = await loadExperimentAssignment(
`woocommerce_product_creation_experience_${ year }${ month }_v1`
);
if ( assignment.variationName === 'treatment' ) {
navigateTo( { url: getNewPath( {}, '/add-product', {} ) } );
return;
}
}
try {
const data: {
id?: number;

View File

@ -0,0 +1,4 @@
Significance: minor
Type: tweak
Redirect to new product experience when in experiment group