Skip to content

Commit

Permalink
Plans: Disable longer plan term default in logged-in plans page (#97129)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskmnds authored Dec 6, 2024
1 parent bcb509f commit 72fa5c2
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions client/my-sites/plans/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import {
PLAN_WOOEXPRESS_MEDIUM_MONTHLY,
PLAN_WOOEXPRESS_SMALL,
PLAN_WOOEXPRESS_SMALL_MONTHLY,
getBillingMonthsForTerm,
URL_FRIENDLY_TERMS_MAPPING,
} from '@automattic/calypso-products';
import page from '@automattic/calypso-router';
import { WpcomPlansUI, Plans } from '@automattic/data-stores';
Expand Down Expand Up @@ -41,7 +39,6 @@ import { PerformanceTrackerStop } from 'calypso/lib/performance-tracking';
import PlansNavigation from 'calypso/my-sites/plans/navigation';
import P2PlansMain from 'calypso/my-sites/plans/p2-plans-main';
import PlansFeaturesMain from 'calypso/my-sites/plans-features-main';
import useLongerPlanTermDefaultExperiment from 'calypso/my-sites/plans-features-main/hooks/experiments/use-longer-plan-term-default-experiment';
import { useSelector } from 'calypso/state';
import { getByPurchaseId } from 'calypso/state/purchases/selectors';
import { canCurrentUser } from 'calypso/state/selectors/can-current-user';
Expand Down Expand Up @@ -557,30 +554,22 @@ export default function PlansWrapper( props ) {
const { intervalType: intervalTypeFromProps } = props;
const selectedSiteId = useSelector( getSelectedSiteId );
const currentPlan = Plans.useCurrentPlan( { siteId: selectedSiteId } );
const longerPlanTermDefaultExperiment = useLongerPlanTermDefaultExperiment();
/**
* For WP.com plans page, if intervalType is not explicitly specified in the URL,
* we want to show plans of the same term as plan that is currently active
* We want to show the highest term between the current plan and the longer plan term default experiment
*/
const currentPlanTerm = useSelector( ( state ) =>
const intervalTypeForCurrentPlanTerm = useSelector( ( state ) =>
getIntervalTypeForTerm( getCurrentPlanTerm( state, selectedSiteId ) )
);
const intervalType =
longerPlanTermDefaultExperiment.term &&
currentPlanTerm &&
getBillingMonthsForTerm( URL_FRIENDLY_TERMS_MAPPING[ currentPlanTerm ] ) >
getBillingMonthsForTerm( URL_FRIENDLY_TERMS_MAPPING[ longerPlanTermDefaultExperiment.term ] )
? currentPlanTerm
: longerPlanTermDefaultExperiment.term;

return (
<CalypsoShoppingCartProvider>
<ConnectedPlans
{ ...props }
currentPlan={ currentPlan }
selectedSiteId={ selectedSiteId }
intervalType={ intervalTypeFromProps ?? intervalType ?? currentPlanTerm }
intervalType={ intervalTypeFromProps ?? intervalTypeForCurrentPlanTerm }
/>
</CalypsoShoppingCartProvider>
);
Expand Down

0 comments on commit 72fa5c2

Please sign in to comment.