Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plans: Disable longer plan term default in logged-in plans page #97129

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading