diff --git a/ghost/admin/app/controllers/offer.js b/ghost/admin/app/controllers/offer.js index 22277fd5f1..3f674613b2 100644 --- a/ghost/admin/app/controllers/offer.js +++ b/ghost/admin/app/controllers/offer.js @@ -82,6 +82,14 @@ export default class OffersController extends Controller { }; } + get isTrialOffer() { + return this.offer?.type === 'trial'; + } + + get isDiscountOffer() { + return this.offer?.type !== 'trial'; + } + get cadence() { if (this.offer.tier && this.offer.cadence) { const tier = this.tiers.findBy('id', this.offer.tier.id); @@ -312,6 +320,15 @@ export default class OffersController extends Controller { this._saveOfferProperty('amount', amount); } + @action + setTrialDuration(e) { + let amount = e.target.value; + if (amount !== '') { + amount = parseInt(amount); + } + this._saveOfferProperty('amount', amount); + } + @action setOfferName(e) { this._saveOfferProperty('name', e.target.value); @@ -418,6 +435,19 @@ export default class OffersController extends Controller { } } + @action + changeType(type) { + if (type === 'trial') { + this._saveOfferProperty('type', 'trial'); + this._saveOfferProperty('amount', 0); + this._saveOfferProperty('duration', 'trial'); + } else { + this._saveOfferProperty('type', 'percent'); + this._saveOfferProperty('amount', 0); + this._saveOfferProperty('duration', 'once'); + } + } + @action updateCadence(cadence, offerObj) { offerObj = offerObj || this.offer; diff --git a/ghost/admin/app/templates/offer.hbs b/ghost/admin/app/templates/offer.hbs index 79ad1ae940..d6019b6fd1 100644 --- a/ghost/admin/app/templates/offer.hbs +++ b/ghost/admin/app/templates/offer.hbs @@ -46,13 +46,18 @@
{{#if (feature 'freeTrial')}} -
- -
- - +
+ +
+ + +
-
{{/if}} @@ -70,22 +75,28 @@ - {{!--
+ {{#if this.isTrialOffer}} +
+ @class="gh-input" + />
- +
-
--}} +
+ {{else}}
@@ -175,6 +186,7 @@ {{/if}}
+ {{/if}}

Portal settings

diff --git a/ghost/admin/app/validators/offer.js b/ghost/admin/app/validators/offer.js index 09563fab8c..525a1137a5 100644 --- a/ghost/admin/app/validators/offer.js +++ b/ghost/admin/app/validators/offer.js @@ -17,7 +17,11 @@ export default BaseValidator.create({ amount(model) { if (!model.amount) { - model.errors.add('amount', 'Please enter the amount.'); + if (model.type === 'trial') { + model.errors.add('amount', 'Please enter the trial duration.'); + } else { + model.errors.add('amount', 'Please enter the amount.'); + } this.invalidate(); } },