Skip to content

Commit

Permalink
Adds Creator as an upsell to the Newsletter recommendation card (#34350)
Browse files Browse the repository at this point in the history
* adding Creator as a sidebar product upsell on the newsletter card

* changelog

* tweaks

---------

Co-authored-by: Mike Stott <mikestott@Mikes-MacBook-Pro.local>
  • Loading branch information
mikestottuk and Mike Stott authored Nov 29, 2023
1 parent 705f55e commit 0675b93
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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: __(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -62,6 +63,7 @@ import {
getSitePurchases,
hasActiveProductPurchase,
hasActiveSecurityPurchase,
hasActiveCreatorPurchase,
siteHasFeature,
isFetchingSiteData,
hasActiveAntiSpamPurchase,
Expand Down Expand Up @@ -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' ) &&
Expand Down
26 changes: 26 additions & 0 deletions projects/plugins/jetpack/_inc/client/state/site/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
isJetpackBoost,
isJetpackProduct,
isJetpackSearch,
isJetpackCreator,
isJetpackSecurityBundle,
isJetpackAntiSpam,
isSecurityComparableJetpackLegacyPlan,
Expand Down Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: enhancement

Adds a product upsell for Creator to the Newsletter recommendation card
15 changes: 15 additions & 0 deletions projects/plugins/jetpack/class.jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
25 changes: 25 additions & 0 deletions projects/plugins/jetpack/images/recommendations/creator-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0675b93

Please sign in to comment.