Skip to content

Commit

Permalink
Search: redirect to plans for purchasing for private sites. (#44062)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnaMag authored Jul 13, 2020
1 parent c7e1b7a commit 0a9ac92
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions client/my-sites/checkout/checkout/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ import {
import { isExternal, addQueryArgs } from 'lib/url';
import { withLocalizedMoment } from 'components/localized-moment';
import { abtest } from 'lib/abtest';
import isPrivateSite from 'state/selectors/is-private-site';

/**
* Style dependencies
Expand Down Expand Up @@ -291,7 +292,7 @@ export class Checkout extends React.Component {
}

addNewItemToCart() {
const { planSlug, product, cart, isJetpackNotAtomic } = this.props;
const { planSlug, product, cart, isJetpackNotAtomic, isPrivate } = this.props;

let cartItem, cartMeta;

Expand All @@ -314,18 +315,25 @@ export class Checkout extends React.Component {
}

if ( JETPACK_SEARCH_PRODUCTS.includes( product ) ) {
if ( isPrivate ) {
cartItem = null;
}
if ( isJetpackNotAtomic ) {
cartItem = product.includes( 'monthly' )
? jetpackProductItem( PRODUCT_JETPACK_SEARCH_MONTHLY )
: jetpackProductItem( PRODUCT_JETPACK_SEARCH );
}

if ( config.isEnabled( 'jetpack/wpcom-search-product' ) && ! isJetpackNotAtomic ) {
if (
config.isEnabled( 'jetpack/wpcom-search-product' ) &&
! isJetpackNotAtomic &&
! isPrivate
) {
cartItem = product.includes( 'monthly' )
? jetpackProductItem( PRODUCT_WPCOM_SEARCH_MONTHLY )
: jetpackProductItem( PRODUCT_WPCOM_SEARCH );
} else {
cartItem = ! isJetpackNotAtomic ? null : cartItem;
cartItem = ! isJetpackNotAtomic || ! isPrivate ? null : cartItem;
}
} else if ( JETPACK_PRODUCTS_LIST.includes( product ) && isJetpackNotAtomic ) {
cartItem = jetpackProductItem( product );
Expand Down Expand Up @@ -990,6 +998,7 @@ export default connect(
productsList: getProductsList( state ),
isProductsListFetching: isProductsListFetching( state ),
isPlansListFetching: isRequestingPlans( state ),
isPrivate: isPrivateSite( state, selectedSiteId ),
isSitePlansListFetching: isRequestingSitePlans( state, selectedSiteId ),
planSlug: getUpgradePlanSlugFromPath( state, selectedSiteId, props.product ),
isJetpackNotAtomic:
Expand Down

0 comments on commit 0a9ac92

Please sign in to comment.