From 6c2869db618534d37b7909a7e2b9d8df27c17c61 Mon Sep 17 00:00:00 2001 From: Rishabh Date: Fri, 7 May 2021 15:14:56 +0530 Subject: [PATCH] Updated products/prices data in member site settings refs https://github.com/TryGhost/Team/issues/637 refs https://github.com/TryGhost/Ghost/commit/75169b705be07a7bc5c7d59d0f0c971b1d18d2ca With custom prices, Portal now needs to show all available custom prices in the UI as well as product's name and description in the Portal UI. This change adds product information to member site settings for Portal UI. --- core/server/services/members/middleware.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core/server/services/members/middleware.js b/core/server/services/members/middleware.js index 7c2917f1c0..401df6c1c6 100644 --- a/core/server/services/members/middleware.js +++ b/core/server/services/members/middleware.js @@ -85,9 +85,13 @@ const getDefaultProductPrices = async function () { if (product) { const model = await membersService.api.productRepository.get({id: product.get('id')}, {withRelated: ['stripePrices']}); const productData = model.toJSON(); - return productData.stripePrices || []; + const prices = productData.stripePrices || []; + return { + product: productData, + prices + }; } - return []; + return {}; }; const getMemberSiteData = async function (req, res) { @@ -99,7 +103,7 @@ const getMemberSiteData = async function (req, res) { if (!supportAddress.includes('@')) { supportAddress = `${supportAddress}@${blogDomain}`; } - const defaultPrices = await getDefaultProductPrices(); + const {product = {}, prices = []} = await getDefaultProductPrices() || {}; const response = { title: settingsCache.get('title'), description: settingsCache.get('description'), @@ -109,7 +113,11 @@ const getMemberSiteData = async function (req, res) { url: urlUtils.urlFor('home', true), version: ghostVersion.safe, plans: membersService.config.getPublicPlans(), - prices: defaultPrices, + prices, + product: { + name: product.name || '', + description: product.description || '' + }, allow_self_signup: membersService.config.getAllowSelfSignup(), members_signup_access: settingsCache.get('members_signup_access'), is_stripe_configured: isStripeConfigured,