diff --git a/ghost/portal/src/App.js b/ghost/portal/src/App.js index d60ae5e365..abc2b59b45 100644 --- a/ghost/portal/src/App.js +++ b/ghost/portal/src/App.js @@ -10,7 +10,7 @@ import {getActivePage, isAccountPage, isOfferPage} from './pages'; import ActionHandler from './actions'; import './App.css'; import NotificationParser from './utils/notifications'; -import {createPopupNotification, getCurrencySymbol, getFirstpromoterId, getPriceIdFromPageQuery, getProductFromId, getQueryPrice, getSiteDomain, isActiveOffer, isComplimentaryMember, isInviteOnlySite, isPaidMember, isSentryEventAllowed, removePortalLinkFromUrl} from './utils/helpers'; +import {createPopupNotification, getCurrencySymbol, getFirstpromoterId, getPriceIdFromPageQuery, getProductCadenceFromPrice, getProductFromId, getQueryPrice, getSiteDomain, isActiveOffer, isComplimentaryMember, isInviteOnlySite, isPaidMember, isSentryEventAllowed, removePortalLinkFromUrl} from './utils/helpers'; const {handleDataAttributes} = require('./data-attributes'); const React = require('react'); @@ -619,9 +619,11 @@ export default class App extends React.Component { page: 'loading' }); if (member) { - this.dispatchAction('checkoutPlan', {plan: price.id, offerId}); + const {tierId, cadence} = getProductCadenceFromPrice({site, priceId: price.id}); + this.dispatchAction('checkoutPlan', {plan: price.id, offerId, tierId, cadence}); } else { - this.dispatchAction('signup', {plan: price.id, offerId}); + const {tierId, cadence} = getProductCadenceFromPrice({site, priceId: price.id}); + this.dispatchAction('signup', {plan: price.id, offerId, tierId, cadence}); } } else { this.dispatchAction('openPopup', { @@ -659,7 +661,8 @@ export default class App extends React.Component { page: 'loading' }); } - this.dispatchAction('signup', {plan}); + const {tierId, cadence} = getProductCadenceFromPrice({site, priceId: plan}); + this.dispatchAction('signup', {plan, tierId, cadence}); } } diff --git a/ghost/portal/src/actions.js b/ghost/portal/src/actions.js index ad2bb36c84..65318692db 100644 --- a/ghost/portal/src/actions.js +++ b/ghost/portal/src/actions.js @@ -95,12 +95,16 @@ async function signin({data, api, state}) { async function signup({data, state, api}) { try { - const {plan, email, name, newsletters, offerId} = data; + let {plan, tierId, cadence, email, name, newsletters, offerId} = data; if (plan.toLowerCase() === 'free') { await api.member.sendMagicLink(data); } else { - const {tierId, cadence} = getProductCadenceFromPrice({site: state?.site, priceId: plan}); - await api.member.checkoutPlan({plan, tierId, cadence, email, name, newsletters, offerId}); + if (tierId && cadence) { + await api.member.checkoutPlan({plan, tierId, cadence, email, name, newsletters, offerId}); + } else { + ({tierId, cadence} = getProductCadenceFromPrice({site: state?.site, priceId: plan})); + await api.member.checkoutPlan({plan, tierId, cadence, email, name, newsletters, offerId}); + } } return { page: 'magiclink', @@ -119,8 +123,10 @@ async function signup({data, state, api}) { async function checkoutPlan({data, state, api}) { try { - const {plan, offerId} = data; - const {tierId, cadence} = getProductCadenceFromPrice({site: state?.site, priceId: plan}); + let {plan, offerId, tierId, cadence} = data; + if (!tierId || !cadence) { + ({tierId, cadence} = getProductCadenceFromPrice({site: state?.site, priceId: plan})); + } await api.member.checkoutPlan({ plan, tierId,