mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Fixed offers index pricing decimals (#19125)
no issue - changes the price tags on the offer cards to two decimal places.
This commit is contained in:
parent
41ee387af2
commit
62b71fb4c0
1 changed files with 6 additions and 3 deletions
|
@ -34,7 +34,10 @@ export const getOfferDiscount = (type: string, amount: number, cadence: string,
|
|||
let discountOffer = '';
|
||||
const originalPrice = cadence === 'month' ? tier?.monthly_price ?? 0 : tier?.yearly_price ?? 0;
|
||||
let updatedPrice = originalPrice;
|
||||
let originalPriceWithCurrency = getSymbol(currency) + numberWithCommas(currencyToDecimal(originalPrice));
|
||||
|
||||
const formatToTwoDecimals = (num: number): number => parseFloat(num.toFixed(2));
|
||||
|
||||
let originalPriceWithCurrency = getSymbol(currency) + numberWithCommas(formatToTwoDecimals(currencyToDecimal(originalPrice)));
|
||||
|
||||
switch (type) {
|
||||
case 'percent':
|
||||
|
@ -44,7 +47,7 @@ export const getOfferDiscount = (type: string, amount: number, cadence: string,
|
|||
break;
|
||||
case 'fixed':
|
||||
discountColor = 'text-blue';
|
||||
discountOffer = numberWithCommas(currencyToDecimal(amount)) + ' ' + currency + ' off';
|
||||
discountOffer = numberWithCommas(formatToTwoDecimals(currencyToDecimal(amount))) + ' ' + currency + ' off';
|
||||
updatedPrice = originalPrice - amount;
|
||||
break;
|
||||
case 'trial':
|
||||
|
@ -56,7 +59,7 @@ export const getOfferDiscount = (type: string, amount: number, cadence: string,
|
|||
break;
|
||||
};
|
||||
|
||||
const updatedPriceWithCurrency = getSymbol(currency) + numberWithCommas(currencyToDecimal(updatedPrice));
|
||||
const updatedPriceWithCurrency = getSymbol(currency) + numberWithCommas(formatToTwoDecimals(currencyToDecimal(updatedPrice)));
|
||||
|
||||
return {
|
||||
discountColor,
|
||||
|
|
Loading…
Add table
Reference in a new issue