From 0675b93f466ec24a94d96dd118196cf15972aaca Mon Sep 17 00:00:00 2001 From: Mike Stott Date: Wed, 29 Nov 2023 16:05:57 +0000 Subject: [PATCH] Adds Creator as an upsell to the Newsletter recommendation card (#34350) * adding Creator as a sidebar product upsell on the newsletter card * changelog * tweaks --------- Co-authored-by: Mike Stott --- .../product-description/test/fixtures.js | 15 +++++++++++ .../client/recommendations/feature-utils.js | 13 ++++++++++ .../client/state/recommendations/reducer.js | 7 +++++ .../jetpack/_inc/client/state/site/reducer.js | 26 +++++++++++++++++++ .../add-creator-promo-newsletter-recommend | 4 +++ projects/plugins/jetpack/class.jetpack.php | 15 +++++++++++ .../images/recommendations/creator-icon.svg | 25 ++++++++++++++++++ 7 files changed, 105 insertions(+) create mode 100644 projects/plugins/jetpack/changelog/add-creator-promo-newsletter-recommend create mode 100644 projects/plugins/jetpack/images/recommendations/creator-icon.svg diff --git a/projects/plugins/jetpack/_inc/client/product-descriptions/product-description/test/fixtures.js b/projects/plugins/jetpack/_inc/client/product-descriptions/product-description/test/fixtures.js index 4386ab72efaba..6ecb8ec30b0ba 100644 --- a/projects/plugins/jetpack/_inc/client/product-descriptions/product-description/test/fixtures.js +++ b/projects/plugins/jetpack/_inc/client/product-descriptions/product-description/test/fixtures.js @@ -28,6 +28,21 @@ export function buildInitialState() { url: 'https://cloud.jetpack.com/pricing#backup-storage-limits-faq', }, }, + creator: { + title: 'Jetpack Creator', + slug: 'jetpack_creator_yearly', + description: + 'Craft stunning content, boost your subscriber base, and monetize your online presence.', + show_promotion: true, + discount_percent: 50, + included_in_plans: [ 'complete' ], + features: [ + 'Unlimited subscriber imports', + 'Earn more from your content', + 'Accept payments with PayPal', + 'Increase earnings with WordAds', + ], + }, scan: { title: 'Jetpack Scan', slug: 'jetpack_scan', diff --git a/projects/plugins/jetpack/_inc/client/recommendations/feature-utils.js b/projects/plugins/jetpack/_inc/client/recommendations/feature-utils.js index 3977a2124152a..121e1153ccffd 100644 --- a/projects/plugins/jetpack/_inc/client/recommendations/feature-utils.js +++ b/projects/plugins/jetpack/_inc/client/recommendations/feature-utils.js @@ -7,6 +7,7 @@ import { PLAN_JETPACK_VIDEOPRESS, PLAN_JETPACK_ANTI_SPAM, PLAN_JETPACK_BACKUP_T1_YEARLY, + PLAN_JETPACK_CREATOR_YEARLY, } from 'lib/plans/constants'; import { getSiteAdminUrl, @@ -720,6 +721,18 @@ export const getProductCardData = ( state, productSlug ) => { productCardList: products.security ? products.security.features : [], productCardIcon: '/recommendations/cloud-icon.svg', }; + // Creator Plan + case PLAN_JETPACK_CREATOR_YEARLY: + return { + productCardTitle: __( 'Grow and monetize your audience', 'jetpack' ), + productCardCtaLink: getRedirectUrl( 'jetpack-recommendations-product-checkout', { + site: siteRawUrl, + path: productSlug, + } ), + productCardCtaText: __( 'Get Jetpack Creator', 'jetpack' ), + productCardList: products.creator ? products.creator.features : [], + productCardIcon: '/recommendations/creator-icon.svg', + }; case PLAN_JETPACK_ANTI_SPAM: return { productCardTitle: __( diff --git a/projects/plugins/jetpack/_inc/client/state/recommendations/reducer.js b/projects/plugins/jetpack/_inc/client/state/recommendations/reducer.js index bae91b58de5b2..2802970219c49 100644 --- a/projects/plugins/jetpack/_inc/client/state/recommendations/reducer.js +++ b/projects/plugins/jetpack/_inc/client/state/recommendations/reducer.js @@ -5,6 +5,7 @@ import { PLAN_JETPACK_VIDEOPRESS, PLAN_JETPACK_ANTI_SPAM, PLAN_JETPACK_BACKUP_T1_YEARLY, + PLAN_JETPACK_CREATOR_YEARLY, getPlanClass, } from 'lib/plans/constants'; import { assign, difference, get, isArray, isEmpty, mergeWith, union } from 'lodash'; @@ -62,6 +63,7 @@ import { getSitePurchases, hasActiveProductPurchase, hasActiveSecurityPurchase, + hasActiveCreatorPurchase, siteHasFeature, isFetchingSiteData, hasActiveAntiSpamPurchase, @@ -551,6 +553,11 @@ export const getProductSlugForStep = ( state, step ) => { return PLAN_JETPACK_BACKUP_T1_YEARLY; } break; + case 'newsletter': + if ( ! hasActiveCreatorPurchase( state ) ) { + return PLAN_JETPACK_CREATOR_YEARLY; + } + break; case 'anti-spam': if ( ! isPluginActive( state, 'akismet/akismet.php' ) && diff --git a/projects/plugins/jetpack/_inc/client/state/site/reducer.js b/projects/plugins/jetpack/_inc/client/state/site/reducer.js index 711582a3c8851..736c873ea0f2e 100644 --- a/projects/plugins/jetpack/_inc/client/state/site/reducer.js +++ b/projects/plugins/jetpack/_inc/client/state/site/reducer.js @@ -5,6 +5,7 @@ import { isJetpackBoost, isJetpackProduct, isJetpackSearch, + isJetpackCreator, isJetpackSecurityBundle, isJetpackAntiSpam, isSecurityComparableJetpackLegacyPlan, @@ -434,6 +435,31 @@ export function hasActiveSearchPurchase( state ) { ); } +/** + * Searches active products for Creator product + * + * @param {object} state - Global state tree + * @returns {object} An active Creator product if one was found, undefined otherwise. + */ +export function getActiveCreatorPurchase( state ) { + return find( getActiveProductPurchases( state ), product => + isJetpackCreator( product.product_slug ) + ); +} + +/** + * Determines if the site has an active Creator product purchase + * + * @param {object} state - Global state tree + * @returns {boolean} True if the site has an active Creator product purchase, false otherwise. + */ +export function hasActiveCreatorPurchase( state ) { + return ( + !! getActiveCreatorPurchase( state ) || + 'is-complete-plan' === getPlanClass( getSitePlan( state ).product_slug ) + ); +} + /** * Searches active products for an active Anti-Spam product. * diff --git a/projects/plugins/jetpack/changelog/add-creator-promo-newsletter-recommend b/projects/plugins/jetpack/changelog/add-creator-promo-newsletter-recommend new file mode 100644 index 0000000000000..b24ac3c103ba1 --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-creator-promo-newsletter-recommend @@ -0,0 +1,4 @@ +Significance: minor +Type: enhancement + +Adds a product upsell for Creator to the Newsletter recommendation card diff --git a/projects/plugins/jetpack/class.jetpack.php b/projects/plugins/jetpack/class.jetpack.php index 651d3a7d5957f..e8e73a38de240 100644 --- a/projects/plugins/jetpack/class.jetpack.php +++ b/projects/plugins/jetpack/class.jetpack.php @@ -6766,6 +6766,21 @@ public static function get_products_for_purchase( $show_legacy = false ) { ), ); + $products['creator'] = array( + 'title' => __( 'Jetpack Creator', 'jetpack' ), + 'slug' => 'jetpack_creator_yearly', + 'description' => __( 'Craft stunning content, boost your subscriber base, and monetize your online presence.', 'jetpack' ), + 'show_promotion' => true, + 'discount_percent' => 50, + 'included_in_plans' => array( 'complete' ), + 'features' => array( + _x( 'Unlimited subscriber imports', 'Creator Product Feature', 'jetpack' ), + _x( 'Earn more from your content', 'Creator Product Feature', 'jetpack' ), + _x( 'Accept payments with PayPal', 'Creator Product Feature', 'jetpack' ), + _x( 'Increase earnings with WordAds', 'Creator Product Feature', 'jetpack' ), + ), + ); + $products['scan'] = array( 'title' => __( 'Jetpack Scan', 'jetpack' ), 'slug' => 'jetpack_scan', diff --git a/projects/plugins/jetpack/images/recommendations/creator-icon.svg b/projects/plugins/jetpack/images/recommendations/creator-icon.svg new file mode 100644 index 0000000000000..711118470fcb0 --- /dev/null +++ b/projects/plugins/jetpack/images/recommendations/creator-icon.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + +