diff --git a/ghost/portal/src/components/pages/OfferPage.js b/ghost/portal/src/components/pages/OfferPage.js index 442a966c96..c6527aebcf 100644 --- a/ghost/portal/src/components/pages/OfferPage.js +++ b/ghost/portal/src/components/pages/OfferPage.js @@ -358,7 +358,7 @@ export default class OfferPage extends React.Component { getOriginalPrice({offer, product}) { const price = offer.cadence === 'month' ? product.monthlyPrice : product.yearlyPrice; - const originalAmount = price.amount / 100; + const originalAmount = this.renderRoundedPrice(price.amount / 100); return `${getCurrencySymbol(price.currency)}${originalAmount}/${offer.cadence}`; } @@ -376,6 +376,14 @@ export default class OfferPage extends React.Component { return originalAmount / 100; } + renderRoundedPrice(price) { + if (price % 1 !== 0) { + const roundedPrice = Math.round(price * 100) / 100; + return Number(roundedPrice).toFixed(2); + } + return price; + } + getOffAmount({offer}) { if (offer.type === 'fixed') { return `${getCurrencySymbol(offer.currency)}${offer.amount / 100}`; @@ -392,6 +400,8 @@ export default class OfferPage extends React.Component { } const product = getProductFromId({site, productId: offer.tier.id}); const price = offer.cadence === 'month' ? product.monthlyPrice : product.yearlyPrice; + const updatedPrice = this.getUpdatedPrice({offer, product}); + const originalPrice = this.getOriginalPrice({offer, product}); return ( <>
@@ -418,7 +428,7 @@ export default class OfferPage extends React.Component {
{getCurrencySymbol(price.currency)}{price.amount / 100}
{getCurrencySymbol(price.currency)} - {this.getUpdatedPrice({offer, product})} + {this.renderRoundedPrice(updatedPrice)}