Skip to content

Commit

Permalink
Use plugin_name to include woocommerce-payments in the woocommerce co…
Browse files Browse the repository at this point in the history
…re profiler
  • Loading branch information
moon0326 committed Sep 30, 2024
1 parent b462b78 commit 80a9c95
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions client/state/selectors/is-woocommerce-core-profiler-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,22 @@ import type { AppState } from 'calypso/types';
* @returns {?boolean} Whether the user reached Calypso via the WooCommerce Core Profiler flow
*/
export const isWooCommerceCoreProfilerFlow = ( state: AppState ): boolean => {
const allowedFrom = [ 'woocommerce-core-profiler' ];
const isCoreProfiler =
get( getInitialQueryArguments( state ), 'from' ) === 'woocommerce-core-profiler' ||
get( getCurrentQueryArguments( state ), 'from' ) === 'woocommerce-core-profiler';

const allowedPluginNames = [ 'woocommerce-payment' ];
const isPluginNameAllowed =
allowedPluginNames.includes(
get( getInitialQueryArguments( state ), 'plugin_name' ) as string
) ||
allowedPluginNames.includes(
get( getCurrentQueryArguments( state ), 'plugin_name' ) as string
);

return (
allowedFrom.includes( get( getInitialQueryArguments( state ), 'from' ) as string ) ||
allowedFrom.includes( get( getCurrentQueryArguments( state ), 'from' ) as string ) ||
isCoreProfiler ||
isPluginNameAllowed ||
( config.isEnabled( 'woocommerce/core-profiler-passwordless-auth' ) &&
new URLSearchParams( state.login?.redirectTo?.original ).get( 'from' ) ===
'woocommerce-core-profiler' )
Expand Down

0 comments on commit 80a9c95

Please sign in to comment.