Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jetpack Search: enable purchases via "...search/yearly" routes. #43865

Merged
merged 3 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions client/jetpack-connect/jetpack-connection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import debugModule from 'debug';
import config from 'config';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { flowRight, get, includes, startsWith, omit } from 'lodash';
import { flowRight, get, includes, omit } from 'lodash';
import { localize } from 'i18n-calypso';

/**
Expand Down Expand Up @@ -197,9 +197,12 @@ const jetpackConnection = ( WrappedComponent ) => {
}

if ( this.checkProperty( 'isWordPressDotCom' ) ) {
const product = window.location.href.split( '/' )[ 5 ];
const product_path = window.location.pathname;

if ( startsWith( product, 'jetpack_search' ) || startsWith( product, 'wpcom_search' ) ) {
if (
product_path.includes( 'jetpack_search' ) ||
product_path.includes( 'wpcom_search' )
) {
return IS_DOT_COM_GET_SEARCH;
}
return IS_DOT_COM;
Expand All @@ -209,15 +212,6 @@ const jetpackConnection = ( WrappedComponent ) => {
return SITE_BLOCKED;
}

if ( this.checkProperty( 'isWordPressDotCom' ) ) {
const product = window.location.href.split( '/' )[ 5 ];

if ( startsWith( product, 'jetpack_search' ) ) {
return IS_DOT_COM_GET_SEARCH;
}
return IS_DOT_COM;
}

if ( this.props.jetpackConnectSite.installConfirmedByUser === false ) {
return NOT_JETPACK;
}
Expand Down
14 changes: 11 additions & 3 deletions client/jetpack-connect/search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,18 @@ export class SearchPurchase extends Component {
}

getProduct() {
const product = window.location.pathname.split( '/' )[ 3 ];
const type = window.location.pathname.split( '/' )[ 4 ];
const type = window.location.pathname.includes( 'monthly' ) && 'monthly';
let product = '';

return [ 'monthly', 'yearly' ].includes( type ) ? product + '_' + type : product;
if ( window.location.pathname.includes( 'jetpack_search' ) ) {
product = type ? 'jetpack_search_monthly' : 'jetpack_search';
}

if ( window.location.pathname.includes( 'wpcom_search' ) ) {
product = type ? 'wpcom_search_monthly' : 'wpcom_search';
}

return product;
}

renderSiteInput( status ) {
Expand Down
2 changes: 1 addition & 1 deletion client/my-sites/checkout/checkout/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export class Checkout extends React.Component {
? jetpackProductItem( 'wpcom_search_monthly' )
: jetpackProductItem( 'wpcom_search' );
} else {
cartItem = null;
cartItem = ! isJetpackNotAtomic ? null : cartItem;
}
}

Expand Down