Skip to content

Commit

Permalink
Move user to /plans page when exiting and clearing cart from checkout (
Browse files Browse the repository at this point in the history
…#99174)

* Fix the exit checkout flow by proper redirecting back to /plans page

* Refactor backDestination logic

Update `getPostCheckoutDestination` to return both destination and
backDestination. That way we're sharing the same logic for determing
whether this is the big sky flow or not.

---------

Co-authored-by: Philip Jackson <[email protected]>
  • Loading branch information
paulopmt1 and p-jackson authored Feb 2, 2025
1 parent 3e12267 commit 8863e5c
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions client/landing/stepper/declarative-flow/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,24 +162,33 @@ const onboarding: Flow = {
const { isEligible: isBigSkyEligible } = useIsBigSkyEligible();
const isDesignChoicesStepEnabled = isBigSkyEligible && isGoalsAtFrontExperiment;

const getPostCheckoutDestination = ( providedDependencies: ProvidedDependencies ) => {
/**
* Returns [destination, backDestination] for the post-checkout destination.
*/
const getPostCheckoutDestination = (
providedDependencies: ProvidedDependencies
): [ string, string ] => {
if (
createWithBigSky &&
config.isEnabled( 'onboarding/big-sky-before-plans' ) &&
isGoalsAtFrontExperiment
) {
return addQueryArgs( '/setup/site-setup/launch-big-sky', {
const destination = addQueryArgs( '/setup/site-setup/launch-big-sky', {
siteSlug: providedDependencies.siteSlug,
} );

return [ destination, addQueryArgs( '/setup/onboarding/plans', { skippedCheckout: 1 } ) ];
}

return addQueryArgs( '/setup/site-setup', {
const destination = addQueryArgs( '/setup/site-setup', {
siteSlug: providedDependencies.siteSlug,
...( isGoalsAtFrontExperiment && { 'goals-at-front-experiment': true } ),
...( config.isEnabled( 'onboarding/newsletter-goal' ) && {
flags: 'onboarding/newsletter-goal',
} ),
} );

return [ destination, addQueryArgs( destination, { skippedCheckout: 1 } ) ];
};

clearUseMyDomainsQueryParams( currentStepSlug );
Expand Down Expand Up @@ -344,7 +353,8 @@ const onboarding: Flow = {
case 'create-site':
return navigate( 'processing', undefined, true );
case 'processing': {
const destination = getPostCheckoutDestination( providedDependencies );
const [ destination, backDestination ] =
getPostCheckoutDestination( providedDependencies );

persistSignupDestination( destination );
setSignupCompleteFlowName( flowName );
Expand All @@ -358,7 +368,7 @@ const onboarding: Flow = {
addQueryArgs( `/checkout/${ encodeURIComponent( siteSlug ) }`, {
redirect_to: destination,
signup: 1,
checkoutBackUrl: pathToUrl( addQueryArgs( destination, { skippedCheckout: 1 } ) ),
checkoutBackUrl: pathToUrl( backDestination ),
coupon,
} )
);
Expand Down

0 comments on commit 8863e5c

Please sign in to comment.