Skip to content

Commit

Permalink
Disable storage add-on updates to header price if term savings is ena…
Browse files Browse the repository at this point in the history
…bled
  • Loading branch information
jeyip committed Nov 25, 2024
1 parent 2ac5e53 commit 4c47849
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
3 changes: 3 additions & 0 deletions client/my-sites/plans-features-main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ const PlansFeaturesMain = ( {
const { setShowDomainUpsellDialog } = useDispatch( WpcomPlansUI.store );
const domainFromHomeUpsellFlow = useSelector( getDomainFromHomeUpsellInQuery );
const showUpgradeableStorage = config.isEnabled( 'plans/upgradeable-storage' );
const enableTermSavingsPriceDisplay = isEnabled( 'plans/term-savings-price-display' );
const getPlanTypeDestination = usePlanTypeDestinationCallback();

const longerPlanTermDefaultExperiment = useLongerPlanTermDefaultExperiment();
Expand Down Expand Up @@ -409,6 +410,7 @@ const PlansFeaturesMain = ( {
useCheckPlanAvailabilityForPurchase,
useFreeTrialPlanSlugs,
isDomainOnlySite,
enableTermSavingsPriceDisplay,
} );

// we need only the visible ones for features grid (these should extend into plans-ui data store selectors)
Expand All @@ -431,6 +433,7 @@ const PlansFeaturesMain = ( {
useCheckPlanAvailabilityForPurchase,
useFreeTrialPlanSlugs,
isDomainOnlySite,
enableTermSavingsPriceDisplay,
} );

// when `deemphasizeFreePlan` is enabled, the Free plan will be presented as a CTA link instead of a plan card in the features grid.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ interface Props {
* If true, the pricing includes discounts from upgrade credits.
*/
withProratedDiscounts?: boolean;

/**
* TODO: Add more detailed comments because we've decided to make a tempoarary decision around storage-addons
* while the calypso_plans_page_emphasize_longer_plan_savings experiment is running.
*/
enableTermSavingsPriceDisplay?: boolean;
}

function getTotalPrice( planPrice: number | null | undefined, addOnPrice = 0 ): number | null {
Expand All @@ -79,6 +85,7 @@ const usePricingMetaForGridPlans = ( {
useCheckPlanAvailabilityForPurchase,
storageAddOns,
withProratedDiscounts,
enableTermSavingsPriceDisplay,
}: Props ): { [ planSlug: string ]: Plans.PricingMetaForGridPlan } | null => {
// plans - should have a definition for all plans, being the main source of API data
const plans = Plans.usePlans( { coupon } );
Expand Down Expand Up @@ -131,11 +138,12 @@ const usePricingMetaForGridPlans = ( {
const plan = plans.data?.[ planSlug ];
const sitePlan = sitePlans.data?.[ planSlug ];
const selectedStorageOption = selectedStorageOptions?.[ planSlug ];
const selectedStorageAddOn = selectedStorageOption
? storageAddOns?.find( ( addOn ) => {
return addOn?.addOnSlug === selectedStorageOption;
} )
: null;
const selectedStorageAddOn =
selectedStorageOption && ! enableTermSavingsPriceDisplay
? storageAddOns?.find( ( addOn ) => {
return addOn?.addOnSlug === selectedStorageOption;
} )
: null;
const storageAddOnPriceMonthly = selectedStorageAddOn?.prices?.monthlyPrice || 0;
const storageAddOnPriceYearly = selectedStorageAddOn?.prices?.yearlyPrice || 0;

Expand Down
3 changes: 3 additions & 0 deletions packages/plans-grid-next/src/hooks/data-store/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ export interface UseGridPlansParams {
* Used to hide the "Your Plan" label for domain-only sites
*/
isDomainOnlySite?: boolean;
// TODO: Add more detailed comments because we've decided to make a tempoarary decision around storage-addons
// while the calypso_plans_page_emphasize_longer_plan_savings experiment is running.
enableTermSavingsPriceDisplay?: boolean;
}

export type UseGridPlansType = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const useGridPlansForComparisonGrid = ( {
useCheckPlanAvailabilityForPurchase,
useFreeTrialPlanSlugs,
isDomainOnlySite,
enableTermSavingsPriceDisplay,
}: UseGridPlansParams ): GridPlan[] | null => {
const gridPlans = useGridPlans( {
allFeaturesList,
Expand All @@ -46,6 +47,7 @@ const useGridPlansForComparisonGrid = ( {
useCheckPlanAvailabilityForPurchase,
useFreeTrialPlanSlugs,
isDomainOnlySite,
enableTermSavingsPriceDisplay,
} );

const planFeaturesForComparisonGrid = useRestructuredPlanFeaturesForComparisonGrid( {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const useGridPlansForFeaturesGrid = ( {
useFreeTrialPlanSlugs,
highlightLabelOverrides,
isDomainOnlySite,
enableTermSavingsPriceDisplay,
}: UseGridPlansParams ): GridPlan[] | null => {
const gridPlans = useGridPlans( {
allFeaturesList,
Expand All @@ -44,6 +45,7 @@ const useGridPlansForFeaturesGrid = ( {
useFreeTrialPlanSlugs,
highlightLabelOverrides,
isDomainOnlySite,
enableTermSavingsPriceDisplay,
} );

const planFeaturesForFeaturesGrid = usePlanFeaturesForGridPlans( {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ const useGridPlans: UseGridPlansType = ( {
isDisplayingPlansNeededForFeature,
highlightLabelOverrides,
isDomainOnlySite,
enableTermSavingsPriceDisplay,
} ) => {
const freeTrialPlanSlugs = useFreeTrialPlanSlugs?.( {
intent: intent ?? 'default',
Expand Down Expand Up @@ -290,6 +291,7 @@ const useGridPlans: UseGridPlansType = ( {
coupon,
siteId,
useCheckPlanAvailabilityForPurchase,
enableTermSavingsPriceDisplay,
} );

// Null return would indicate that we are still loading the data. No grid without grid plans.
Expand Down

0 comments on commit 4c47849

Please sign in to comment.