From e6ea55f3323292abba532735c224603758e254dd Mon Sep 17 00:00:00 2001 From: Bryan Elliott Date: Wed, 9 Aug 2023 11:46:58 -0400 Subject: [PATCH] Make Stats Commercial "Annual" plan the default billing term. (#80341) --- .../my-sites/stats/stats-purchase/index.tsx | 18 +++++++++-- .../stats-purchase-checkout-redirect.tsx | 7 ++--- .../stats-purchase-commercial.tsx | 30 +++++++++++-------- .../stats-purchase/stats-purchase-wizard.jsx | 4 ++- 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/client/my-sites/stats/stats-purchase/index.tsx b/client/my-sites/stats/stats-purchase/index.tsx index 17d96784fb90d2..a614e7431c0248 100644 --- a/client/my-sites/stats/stats-purchase/index.tsx +++ b/client/my-sites/stats/stats-purchase/index.tsx @@ -1,4 +1,5 @@ import { + PRODUCT_JETPACK_STATS_YEARLY, PRODUCT_JETPACK_STATS_MONTHLY, PRODUCT_JETPACK_STATS_PWYW_YEARLY, PRODUCT_JETPACK_STATS_FREE, @@ -55,7 +56,10 @@ const StatsPurchasePage = ( { query }: { query: { redirect_uri: string; from: st return isProductOwned( siteProducts, PRODUCT_JETPACK_STATS_FREE ); }, [ siteProducts ] ); const isCommercialOwned = useMemo( () => { - return isProductOwned( siteProducts, PRODUCT_JETPACK_STATS_MONTHLY ); + return ( + isProductOwned( siteProducts, PRODUCT_JETPACK_STATS_MONTHLY ) || + isProductOwned( siteProducts, PRODUCT_JETPACK_STATS_YEARLY ) + ); }, [ siteProducts ] ); const isPWYWOwned = useMemo( () => { return isProductOwned( siteProducts, PRODUCT_JETPACK_STATS_PWYW_YEARLY ); @@ -75,6 +79,10 @@ const StatsPurchasePage = ( { query }: { query: { redirect_uri: string; from: st }, [ siteSlug, isCommercialOwned, isSiteJetpackNotAtomic ] ); const commercialProduct = useSelector( ( state ) => + getProductBySlug( state, PRODUCT_JETPACK_STATS_YEARLY ) + ) as ProductsList.ProductsListItem | null; + + const commercialMonthlyProduct = useSelector( ( state ) => getProductBySlug( state, PRODUCT_JETPACK_STATS_MONTHLY ) ) as ProductsList.ProductsListItem | null; @@ -83,7 +91,10 @@ const StatsPurchasePage = ( { query }: { query: { redirect_uri: string; from: st ) as ProductsList.ProductsListItem | null; const isLoading = - ! commercialProduct || ! pwywProduct || ( ! siteProducts && isRequestingSiteProducts ); + ! commercialProduct || + ! commercialMonthlyProduct || + ! pwywProduct || + ( ! siteProducts && isRequestingSiteProducts ); const [ initialStep, initialSiteType ] = useMemo( () => { if ( isPWYWOwned && ! isCommercialOwned ) { @@ -92,6 +103,8 @@ const StatsPurchasePage = ( { query }: { query: { redirect_uri: string; from: st return [ SCREEN_TYPE_SELECTION, TYPE_PERSONAL ]; }, [ isPWYWOwned, isCommercialOwned ] ); + const maxSliderPrice = commercialMonthlyProduct?.cost; + return (
@@ -122,6 +135,7 @@ const StatsPurchasePage = ( { query }: { query: { redirect_uri: string; from: st { const translate = useTranslate(); - const planPriceObject = getCurrencyObject( planValue, currencyCode ); + const planValuePerMonth = planValue / 12; + const planPriceObject = getCurrencyObject( planValuePerMonth, currencyCode ); return (
@@ -50,17 +51,24 @@ const CommercialPurchase = ( {
-
- { planPriceObject.symbol } -
+ { planPriceObject.symbolPosition === 'before' && ( +
+ { planPriceObject.symbol } +
+ ) }
{ planPriceObject.hasNonZeroFraction - ? formatCurrency( planValue, currencyCode ).replace( planPriceObject.symbol, '' ) - : planPriceObject.integer } + ? `${ planPriceObject.integer }${ planPriceObject.fraction }` + : `${ planPriceObject.integer }` }
+ { planPriceObject.symbolPosition === 'after' && ( +
+ { planPriceObject.symbol } +
+ ) }
- /{ translate( 'month' ) } + /{ translate( 'month, billed yearly' ) }
@@ -103,11 +111,7 @@ const CommercialPurchase = ( { gotoCheckoutPage( { from, type: 'commercial', siteSlug, adminUrl, redirectUri } ) } > - { translate( 'Get Jetpack Stats for %(value)s per month', { - args: { - value: formatCurrency( planValue, currencyCode ), - }, - } ) } + { translate( 'Get Jetpack Stats' ) }
); diff --git a/client/my-sites/stats/stats-purchase/stats-purchase-wizard.jsx b/client/my-sites/stats/stats-purchase/stats-purchase-wizard.jsx index 055f6379c5606a..64d6532ea450b9 100644 --- a/client/my-sites/stats/stats-purchase/stats-purchase-wizard.jsx +++ b/client/my-sites/stats/stats-purchase/stats-purchase-wizard.jsx @@ -44,6 +44,7 @@ const ProductCard = ( { siteSlug, siteId, commercialProduct, + maxSliderPrice, pwywProduct, redirectUri, from, @@ -51,7 +52,6 @@ const ProductCard = ( { initialStep = SCREEN_TYPE_SELECTION, initialSiteType = TYPE_PERSONAL, } ) => { - const maxSliderPrice = commercialProduct.cost; const sliderStepPrice = pwywProduct.cost / MIN_STEP_SPLITS; const steps = Math.floor( maxSliderPrice / sliderStepPrice ); @@ -232,6 +232,7 @@ const StatsPurchaseWizard = ( { siteSlug, siteId, commercialProduct, + maxSliderPrice, pwywProduct, redirectUri, from, @@ -244,6 +245,7 @@ const StatsPurchaseWizard = ( { siteSlug={ siteSlug } siteId={ siteId } commercialProduct={ commercialProduct } + maxSliderPrice={ maxSliderPrice } pwywProduct={ pwywProduct } redirectUri={ redirectUri } from={ from }