0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Handled empty prices for product in Portal settings

no refs

Monthly/yearly price values on a product can be `null` when stripe is not connected, this change handles the prices passed to Portal settings to ignore null prices in the array.
This commit is contained in:
Rishabh 2021-06-08 19:41:55 +05:30
parent ba9b2ee68f
commit d2e4f30b5b

View file

@ -84,12 +84,18 @@ const getPortalProductPrices = async function () {
const products = page.data.map((productModel) => {
const product = productModel.toJSON();
const productPrices = [];
if (product.monthlyPrice) {
productPrices.push(product.monthlyPrice);
}
if (product.yearlyPrice) {
productPrices.push(product.yearlyPrice);
}
return {
id: product.id,
name: product.name,
description: product.description || '',
prices: [product.monthlyPrice, product.yearlyPrice]
prices: productPrices
};
});