0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00

Fixed subscription cancellation not working for hidden tiers

closes https://github.com/TryGhost/Team/issues/1119

- updates fetching price from all available products and not just those available to show on Portal
- handles missing price/product on Portal UI gracefully
This commit is contained in:
Rishabh 2021-10-05 11:00:20 +05:30
parent bcbcf7051d
commit 53e463aa4b
3 changed files with 5 additions and 5 deletions

View file

@ -750,7 +750,7 @@ function getSelectedPrice({products, selectedProduct, selectedInterval}) {
selectedPrice = {id: 'free'};
} else {
const product = products.find(prod => prod.id === selectedProduct);
selectedPrice = selectedInterval === 'month' ? product.monthlyPrice : product.yearlyPrice;
selectedPrice = selectedInterval === 'month' ? product?.monthlyPrice : product?.yearlyPrice;
}
return selectedPrice;
}
@ -876,9 +876,9 @@ export function ChangeProductSection({onPlanSelect, selectedPlan, products, type
<ChangeProductCards products={products} />
</div>
<ActionButton
onClick={e => onPlanSelect(null, selectedPrice.id)}
onClick={e => onPlanSelect(null, selectedPrice?.id)}
isRunning={false}
disabled={activePrice.id === selectedPrice.id}
disabled={!selectedPrice?.id || (activePrice.id === selectedPrice?.id)}
isPrimary={true}
brandColor={brandColor}
label={'Continue'}

View file

@ -118,7 +118,7 @@ const PlanConfirmationSection = ({plan, type, onConfirm}) => {
const priceString = formatNumber(plan.price);
const planStartMessage = `${plan.currency_symbol}${priceString}/${plan.interval} Starting ${planStartDate}`;
const product = getProductFromPrice({site, priceId: plan?.id});
const priceLabel = hasMultipleProductsFeature({site}) ? product.name : 'Price';
const priceLabel = hasMultipleProductsFeature({site}) ? product?.name : 'Price';
if (type === 'changePlan') {
return (
<>

View file

@ -328,7 +328,7 @@ export function hasFreeProductPrice({site}) {
}
export function getProductFromPrice({site, priceId}) {
const products = getAvailableProducts({site});
const products = getAllProductsForSite({site});
return products.find((product) => {
return (product?.monthlyPrice?.id === priceId) || (product?.yearlyPrice?.id === priceId);
});