mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Added default description to prices
refs https://github.com/TryGhost/Team/issues/641 When default prices are created via the setup wizard, this adds a default description for Monthly and Yearly prices that mimics the values set for them currently in Portal.
This commit is contained in:
parent
d00d1c2052
commit
575f85a8ca
1 changed files with 11 additions and 0 deletions
|
@ -143,15 +143,25 @@ export default class GhLaunchWizardSetPricingComponent extends Component {
|
||||||
this.args.nextStep();
|
this.args.nextStep();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
calculateDiscount(monthly, yearly) {
|
||||||
|
if (isNaN(monthly) || isNaN(yearly)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return monthly ? 100 - Math.floor((yearly / 12 * 100) / monthly) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
getProduct() {
|
getProduct() {
|
||||||
if (this.product) {
|
if (this.product) {
|
||||||
const stripePrices = this.product.stripePrices || [];
|
const stripePrices = this.product.stripePrices || [];
|
||||||
if (stripePrices.length === 0 && this.stripeMonthlyAmount && this.stripeYearlyAmount) {
|
if (stripePrices.length === 0 && this.stripeMonthlyAmount && this.stripeYearlyAmount) {
|
||||||
|
const yearlyDiscount = this.calculateDiscount(this.stripeMonthlyAmount, this.stripeYearlyAmount);
|
||||||
stripePrices.push(
|
stripePrices.push(
|
||||||
{
|
{
|
||||||
nickname: 'Monthly',
|
nickname: 'Monthly',
|
||||||
amount: this.stripeMonthlyAmount * 100,
|
amount: this.stripeMonthlyAmount * 100,
|
||||||
active: 1,
|
active: 1,
|
||||||
|
description: 'Full Access',
|
||||||
currency: this.currency,
|
currency: this.currency,
|
||||||
interval: 'month',
|
interval: 'month',
|
||||||
type: 'recurring'
|
type: 'recurring'
|
||||||
|
@ -161,6 +171,7 @@ export default class GhLaunchWizardSetPricingComponent extends Component {
|
||||||
amount: this.stripeYearlyAmount * 100,
|
amount: this.stripeYearlyAmount * 100,
|
||||||
active: 1,
|
active: 1,
|
||||||
currency: this.currency,
|
currency: this.currency,
|
||||||
|
description: yearlyDiscount > 0 ? `${yearlyDiscount}% discount` : 'Full Access',
|
||||||
interval: 'month',
|
interval: 'month',
|
||||||
type: 'recurring'
|
type: 'recurring'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue