Skip to content

Commit

Permalink
Redirect to new product experience when in experiment group (woocomme…
Browse files Browse the repository at this point in the history
…rce#36381)

* Redirect to new product experience when in experiment group

* Add changelog entry
  • Loading branch information
joshuatf authored Jan 12, 2023
1 parent ad59769 commit 891ecb7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: tweak

Redirect to new product experience when in experiment group

0 comments on commit 891ecb7

Please sign in to comment.