mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Updated repeating duration offer for monthly cadence only
closes https://github.com/TryGhost/Team/issues/1126 - Offer duration can only allow multiple months for the monthly Cadence
This commit is contained in:
parent
b94bb836f5
commit
4e128a0bd0
1 changed files with 42 additions and 3 deletions
|
@ -118,19 +118,21 @@ export default class OffersController extends Controller {
|
||||||
});
|
});
|
||||||
this.cadences = cadences;
|
this.cadences = cadences;
|
||||||
const defaultCadence = this.cadences[0]?.name;
|
const defaultCadence = this.cadences[0]?.name;
|
||||||
|
const [,interval, defaultCurrency] = (defaultCadence || '').split('-');
|
||||||
|
|
||||||
|
this.updateDurations(interval);
|
||||||
if (this.offer && !this.offer.tier) {
|
if (this.offer && !this.offer.tier) {
|
||||||
this.defaultProps = {};
|
this.defaultProps = {};
|
||||||
this.updateCadence(this.cadences[0]?.name, this.defaultProps);
|
this.updateCadence(defaultCadence, this.defaultProps);
|
||||||
this.updatePortalPreview({forceRefresh: false});
|
this.updatePortalPreview({forceRefresh: false});
|
||||||
} else if (defaultCadence) {
|
} else if (defaultCadence) {
|
||||||
const [,, currency] = (defaultCadence || '').split('-');
|
|
||||||
this.offertypes = [
|
this.offertypes = [
|
||||||
{
|
{
|
||||||
label: '%',
|
label: '%',
|
||||||
offertype: 'percent'
|
offertype: 'percent'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: currency.toUpperCase(),
|
label: defaultCurrency.toUpperCase(),
|
||||||
offertype: 'fixed'
|
offertype: 'fixed'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -370,6 +372,42 @@ export default class OffersController extends Controller {
|
||||||
return this.displayCurrency.length;
|
return this.displayCurrency.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
updateDurations(cadence) {
|
||||||
|
if (cadence) {
|
||||||
|
if (cadence === 'month') {
|
||||||
|
this.durations = [
|
||||||
|
{
|
||||||
|
label: 'Once',
|
||||||
|
duration: 'once'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Forever',
|
||||||
|
duration: 'forever'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Multiple months',
|
||||||
|
duration: 'repeating'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
this.durations = [
|
||||||
|
{
|
||||||
|
label: 'Forever',
|
||||||
|
duration: 'forever'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Once',
|
||||||
|
duration: 'once'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
if (this.offer.duration === 'repeating') {
|
||||||
|
this._saveOfferProperty('duration', 'once');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
updateCadence(cadence, offerObj) {
|
updateCadence(cadence, offerObj) {
|
||||||
offerObj = offerObj || this.offer;
|
offerObj = offerObj || this.offer;
|
||||||
|
@ -390,6 +428,7 @@ export default class OffersController extends Controller {
|
||||||
offertype: 'fixed'
|
offertype: 'fixed'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
this.updateDurations(tierCadence);
|
||||||
this.updatePortalPreview({forceRefresh: false});
|
this.updatePortalPreview({forceRefresh: false});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue