diff --git a/ghost/portal/src/App.js b/ghost/portal/src/App.js index 97848a2ae4..8bb8c430c8 100644 --- a/ghost/portal/src/App.js +++ b/ghost/portal/src/App.js @@ -59,7 +59,8 @@ export default class App extends React.Component { const contextState = this.getContextFromState(); handleDataAttributes({ siteUrl, - site: contextState.site + site: contextState.site, + member: contextState.member }); } } diff --git a/ghost/portal/src/data-attributes.js b/ghost/portal/src/data-attributes.js index 1fa1f6047b..f8db4f2880 100644 --- a/ghost/portal/src/data-attributes.js +++ b/ghost/portal/src/data-attributes.js @@ -2,7 +2,7 @@ const {getQueryPrice} = require('./utils/helpers'); -function handleDataAttributes({siteUrl, site}) { +function handleDataAttributes({siteUrl, site, member}) { siteUrl = siteUrl.replace(/\/$/, ''); Array.prototype.forEach.call(document.querySelectorAll('form[data-members-form]'), function (form) { let errorEl = form.querySelector('[data-members-error]'); @@ -85,6 +85,9 @@ function handleDataAttributes({siteUrl, site}) { errorEl.innerText = ''; } el.classList.add('loading'); + const metadata = member ? { + checkoutType: 'upgrade' + } : {}; fetch(`${siteUrl}/members/api/session`, { credentials: 'same-origin' }).then(function (res) { @@ -102,7 +105,8 @@ function handleDataAttributes({siteUrl, site}) { priceId: priceId, identity: identity, successUrl: checkoutSuccessUrl, - cancelUrl: checkoutCancelUrl + cancelUrl: checkoutCancelUrl, + metadata }) }).then(function (res) { if (!res.ok) {