Skip to content

Commit

Permalink
Goals First: Keep paid domains in the cart when free plan is selected. (
Browse files Browse the repository at this point in the history
#97872)

* Keep paid domains in cart when free plan is selected

* Bypass checkout page if free plan is selected but there are domain items in the cart
  • Loading branch information
vykes-mac authored Jan 1, 2025
1 parent 51d398d commit ff00c28
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const CreateSite: Step = function CreateSite( { navigation, flow, data } ) {
! isNewHostedSiteCreationFlow( flow ) &&
! isSiteAssemblerFlow( flow ) &&
! isMigrationSignupFlow( flow );
const shouldGoToCheckout = Boolean( planCartItem || mergedDomainCartItems.length );
const shouldGoToCheckout = Boolean( planCartItem );

async function createSite() {
if ( isManageSiteFlow ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ export default function PlansStepAdaptor( props: StepProps ) {
const coupon = useQuery().get( 'coupon' ) ?? undefined;
const { data: defaultDesign } = useStarterDesignBySlug( 'twentytwentyfour' );
const [ , isGoalFirstExperiment ] = useGoalsFirstExperiment();
const { setDomainCartItem, setDomainCartItems, setSiteUrl, setSelectedDesign, setPendingAction } =
useWPDispatch( ONBOARD_STORE );
const { setSiteUrl, setSelectedDesign, setPendingAction } = useWPDispatch( ONBOARD_STORE );
const { setDesignOnSite } = useDispatch( SITE_STORE );
const reduxDispatch = useReduxDispatch();

Expand Down Expand Up @@ -137,15 +136,8 @@ export default function PlansStepAdaptor( props: StepProps ) {
setStepState( ( mostRecentState = { ...stepState, ...step } ) );
} }
submitSignupStep={ ( stepInfo ) => {
/* The plans step removes paid domains when the user picks a free plan
after picking a paid domain */
if ( stepInfo.stepName === 'domains' ) {
if ( stepInfo.isPurchasingItem === false ) {
setDomainCartItem( undefined );
setDomainCartItems( undefined );
} else if ( stepInfo.siteUrl ) {
setSiteUrl( stepInfo.siteUrl );
}
if ( stepInfo.stepName === 'domains' && stepInfo.siteUrl ) {
setSiteUrl( stepInfo.siteUrl );
} else {
setStepState( ( mostRecentState = { ...stepState, ...stepInfo } ) );
}
Expand Down

0 comments on commit ff00c28

Please sign in to comment.