@4site/engrid-scripts 0.27.1 → 0.27.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/events/donation-frequency.d.ts +3 -0
- package/dist/events/donation-frequency.js +14 -0
- package/dist/frequency-upsell.js +1 -0
- package/dist/interfaces/upsell-options.d.ts +3 -0
- package/dist/interfaces/upsell-options.js +23 -17
- package/dist/upsell-lightbox.d.ts +3 -1
- package/dist/upsell-lightbox.js +89 -57
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
|
@@ -3,6 +3,8 @@ export declare class DonationFrequency {
|
|
|
3
3
|
private _frequency;
|
|
4
4
|
private _recurring;
|
|
5
5
|
private _dispatch;
|
|
6
|
+
private _frequencies;
|
|
7
|
+
private logger;
|
|
6
8
|
private static instance;
|
|
7
9
|
private constructor();
|
|
8
10
|
static getInstance(): DonationFrequency;
|
|
@@ -11,6 +13,7 @@ export declare class DonationFrequency {
|
|
|
11
13
|
get recurring(): string;
|
|
12
14
|
set recurring(value: string);
|
|
13
15
|
get onFrequencyChange(): import("strongly-typed-events").ISimpleEvent<string>;
|
|
16
|
+
get frequencies(): string[];
|
|
14
17
|
load(): void;
|
|
15
18
|
setRecurrency(recurr: string, dispatch?: boolean): void;
|
|
16
19
|
setFrequency(freq: string, dispatch?: boolean): void;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { SimpleEventDispatcher } from "strongly-typed-events";
|
|
2
2
|
import { ENGrid } from "../engrid";
|
|
3
|
+
import { EngridLogger } from "../logger";
|
|
3
4
|
export class DonationFrequency {
|
|
4
5
|
constructor() {
|
|
5
6
|
this._onFrequencyChange = new SimpleEventDispatcher();
|
|
6
7
|
this._frequency = "onetime";
|
|
7
8
|
this._recurring = "n";
|
|
8
9
|
this._dispatch = true;
|
|
10
|
+
this._frequencies = ["onetime"];
|
|
11
|
+
this.logger = new EngridLogger("DonationFrequency", "white", "black", "💰");
|
|
9
12
|
// Watch the Radios for Changes
|
|
10
13
|
document.addEventListener("change", (e) => {
|
|
11
14
|
const element = e.target;
|
|
@@ -57,6 +60,9 @@ export class DonationFrequency {
|
|
|
57
60
|
get onFrequencyChange() {
|
|
58
61
|
return this._onFrequencyChange.asEvent();
|
|
59
62
|
}
|
|
63
|
+
get frequencies() {
|
|
64
|
+
return this._frequencies;
|
|
65
|
+
}
|
|
60
66
|
// Set amount var with currently selected amount
|
|
61
67
|
load() {
|
|
62
68
|
var _a;
|
|
@@ -73,6 +79,11 @@ export class DonationFrequency {
|
|
|
73
79
|
((_a = window.EngagingNetworks.require._defined.enjs
|
|
74
80
|
.getSupporterData("recurrpay")) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || "n";
|
|
75
81
|
}
|
|
82
|
+
// List of available frequencies on the form
|
|
83
|
+
this._frequencies = Array.from(document.querySelectorAll('input[name="transaction.recurrfreq"]'))
|
|
84
|
+
.filter((el) => el instanceof HTMLInputElement)
|
|
85
|
+
.map((el) => el.value.toLowerCase());
|
|
86
|
+
this.logger.log(`Loaded with frequency: ${this.frequency} and recurring: ${this.recurring} \nAvailable frequencies: ${this._frequencies.join(", ")}`);
|
|
76
87
|
// ENGrid.enParseDependencies();
|
|
77
88
|
}
|
|
78
89
|
// Force a new recurrency
|
|
@@ -109,6 +120,9 @@ export class DonationFrequency {
|
|
|
109
120
|
this.setRecurrency("Y", dispatch);
|
|
110
121
|
}
|
|
111
122
|
}
|
|
123
|
+
else {
|
|
124
|
+
this.logger.warn(`Attempted to set a frequency of "${freq}" but it was not found on the form.`);
|
|
125
|
+
}
|
|
112
126
|
// Revert dispatch to default value (true)
|
|
113
127
|
this._dispatch = true;
|
|
114
128
|
}
|
package/dist/frequency-upsell.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// ! WE ARE PHASING OUT THIS COMPONENT IN FAVOR OF UPSELL-LIGHTBOX. PLEASE USE THAT COMPONENT FOR NEW IMPLEMENTATIONS.
|
|
1
2
|
/*
|
|
2
3
|
* FrequencyUpsell component which creates a modal to upsell the frequency of the donation
|
|
3
4
|
* This is typically used to upsell a single donation into an annual donation, but the component
|
|
@@ -11,11 +11,14 @@ export interface UpsellOptions {
|
|
|
11
11
|
amountRange: Array<{
|
|
12
12
|
max: number;
|
|
13
13
|
suggestion: number | string;
|
|
14
|
+
frequency?: "onetime" | "monthly" | "quarterly" | "semi_annual" | "annual";
|
|
14
15
|
}>;
|
|
16
|
+
upsellToFrequency?: "onetime" | "monthly" | "quarterly" | "semi_annual" | "annual";
|
|
15
17
|
minAmount: number;
|
|
16
18
|
canClose: boolean;
|
|
17
19
|
submitOnClose: boolean;
|
|
18
20
|
oneTime: boolean;
|
|
21
|
+
monthly: boolean;
|
|
19
22
|
annual: boolean;
|
|
20
23
|
disablePaymentMethods: Array<string>;
|
|
21
24
|
skipUpsell: boolean;
|
|
@@ -1,31 +1,37 @@
|
|
|
1
1
|
export const UpsellOptionsDefaults = {
|
|
2
2
|
image: "https://picsum.photos/480/650",
|
|
3
3
|
imagePosition: "left",
|
|
4
|
-
title: "Will you change your gift to just {new-amount}
|
|
5
|
-
paragraph: "Make a
|
|
6
|
-
yesLabel: "Yes! Process My <br> {new-amount}
|
|
7
|
-
noLabel: "No, thanks. Continue with my <br> {old-amount}
|
|
4
|
+
title: "Will you change your gift to just {new-amount} {new-frequency} to boost your impact?",
|
|
5
|
+
paragraph: "Make a {new-frequency} pledge today to support us with consistent, reliable resources during emergency moments.",
|
|
6
|
+
yesLabel: "Yes! Process My <br> {new-amount} {new-frequency} gift",
|
|
7
|
+
noLabel: "No, thanks. Continue with my <br> {old-amount} {old-frequency} gift",
|
|
8
8
|
otherAmount: true,
|
|
9
|
-
otherLabel: "Or enter a different
|
|
9
|
+
otherLabel: "Or enter a different {new-frequency} amount:",
|
|
10
10
|
upsellOriginalGiftAmountFieldName: "",
|
|
11
11
|
amountRange: [
|
|
12
|
-
{ max: 10, suggestion: 5 },
|
|
13
|
-
{ max: 15, suggestion: 7 },
|
|
14
|
-
{ max: 20, suggestion: 8 },
|
|
15
|
-
{ max: 25, suggestion: 9 },
|
|
16
|
-
{ max: 30, suggestion: 10 },
|
|
17
|
-
{ max: 35, suggestion: 11 },
|
|
18
|
-
{ max: 40, suggestion: 12 },
|
|
19
|
-
{ max: 50, suggestion: 14 },
|
|
20
|
-
{ max: 100, suggestion: 15 },
|
|
21
|
-
{ max: 200, suggestion: 19 },
|
|
22
|
-
{ max: 300, suggestion: 29 },
|
|
23
|
-
{
|
|
12
|
+
{ max: 10, suggestion: 5, frequency: "monthly" },
|
|
13
|
+
{ max: 15, suggestion: 7, frequency: "monthly" },
|
|
14
|
+
{ max: 20, suggestion: 8, frequency: "monthly" },
|
|
15
|
+
{ max: 25, suggestion: 9, frequency: "monthly" },
|
|
16
|
+
{ max: 30, suggestion: 10, frequency: "monthly" },
|
|
17
|
+
{ max: 35, suggestion: 11, frequency: "monthly" },
|
|
18
|
+
{ max: 40, suggestion: 12, frequency: "monthly" },
|
|
19
|
+
{ max: 50, suggestion: 14, frequency: "monthly" },
|
|
20
|
+
{ max: 100, suggestion: 15, frequency: "monthly" },
|
|
21
|
+
{ max: 200, suggestion: 19, frequency: "monthly" },
|
|
22
|
+
{ max: 300, suggestion: 29, frequency: "monthly" },
|
|
23
|
+
{
|
|
24
|
+
max: 500,
|
|
25
|
+
suggestion: "Math.ceil((amount / 12)/5)*5",
|
|
26
|
+
frequency: "monthly",
|
|
27
|
+
},
|
|
24
28
|
],
|
|
29
|
+
upsellToFrequency: "monthly",
|
|
25
30
|
minAmount: 0,
|
|
26
31
|
canClose: true,
|
|
27
32
|
submitOnClose: false,
|
|
28
33
|
oneTime: true,
|
|
34
|
+
monthly: false,
|
|
29
35
|
annual: false,
|
|
30
36
|
disablePaymentMethods: [],
|
|
31
37
|
skipUpsell: false,
|
|
@@ -9,15 +9,17 @@ export declare class UpsellLightbox {
|
|
|
9
9
|
private _frequency;
|
|
10
10
|
private _dataLayer;
|
|
11
11
|
private _suggestAmount;
|
|
12
|
+
private _upsellFrequency;
|
|
12
13
|
private logger;
|
|
13
14
|
constructor();
|
|
15
|
+
private parseMergeTags;
|
|
14
16
|
private renderLightbox;
|
|
15
17
|
private shouldRun;
|
|
16
18
|
private shouldSkip;
|
|
17
19
|
private popupOtherField;
|
|
18
20
|
private liveAmounts;
|
|
19
21
|
private liveFrequency;
|
|
20
|
-
private
|
|
22
|
+
private resolveUpsell;
|
|
21
23
|
private shouldOpen;
|
|
22
24
|
private freqAllowed;
|
|
23
25
|
private open;
|
package/dist/upsell-lightbox.js
CHANGED
|
@@ -9,6 +9,7 @@ export class UpsellLightbox {
|
|
|
9
9
|
this._frequency = DonationFrequency.getInstance();
|
|
10
10
|
this._dataLayer = DataLayer.getInstance();
|
|
11
11
|
this._suggestAmount = 0;
|
|
12
|
+
this._upsellFrequency = "monthly";
|
|
12
13
|
this.logger = new EngridLogger("UpsellLightbox", "black", "pink", "🪟");
|
|
13
14
|
let options = "EngridUpsell" in window ? window.EngridUpsell : {};
|
|
14
15
|
this.options = Object.assign(Object.assign({}, UpsellOptionsDefaults), options);
|
|
@@ -26,23 +27,19 @@ export class UpsellLightbox {
|
|
|
26
27
|
this.renderLightbox();
|
|
27
28
|
this._form.onSubmit.subscribe(() => this.open());
|
|
28
29
|
}
|
|
30
|
+
parseMergeTags(str) {
|
|
31
|
+
return str
|
|
32
|
+
.replace(/\{new-amount\}/g, "<span class='upsell_suggestion'></span>")
|
|
33
|
+
.replace(/\{new-frequency\}/g, "<span class='upsell_suggestion_frequency'></span>")
|
|
34
|
+
.replace(/\{old-amount\}/g, "<span class='upsell_amount'></span>")
|
|
35
|
+
.replace(/\{old-frequency\}/g, "<span class='upsell_frequency'></span>");
|
|
36
|
+
}
|
|
29
37
|
renderLightbox() {
|
|
30
|
-
const title = this.options.title
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
.replace("{new-amount}", "<span class='upsell_suggestion'></span>")
|
|
36
|
-
.replace("{old-amount}", "<span class='upsell_amount'></span>")
|
|
37
|
-
.replace("{old-frequency}", "<span class='upsell_frequency'></span>");
|
|
38
|
-
const yes = this.options.yesLabel
|
|
39
|
-
.replace("{new-amount}", "<span class='upsell_suggestion'></span>")
|
|
40
|
-
.replace("{old-amount}", "<span class='upsell_amount'></span>")
|
|
41
|
-
.replace("{old-frequency}", "<span class='upsell_frequency'></span>");
|
|
42
|
-
const no = this.options.noLabel
|
|
43
|
-
.replace("{new-amount}", "<span class='upsell_suggestion'></span>")
|
|
44
|
-
.replace("{old-amount}", "<span class='upsell_amount'></span>")
|
|
45
|
-
.replace("{old-frequency}", "<span class='upsell_frequency'></span>");
|
|
38
|
+
const title = this.parseMergeTags(this.options.title);
|
|
39
|
+
const paragraph = this.parseMergeTags(this.options.paragraph);
|
|
40
|
+
const yes = this.parseMergeTags(this.options.yesLabel);
|
|
41
|
+
const no = this.parseMergeTags(this.options.noLabel);
|
|
42
|
+
const other = this.parseMergeTags(this.options.otherLabel);
|
|
46
43
|
const markup = `
|
|
47
44
|
<div class="upsellLightboxContainer" id="goMonthly">
|
|
48
45
|
<!-- ideal image size is 480x650 pixels -->
|
|
@@ -57,7 +54,7 @@ export class UpsellLightbox {
|
|
|
57
54
|
<div class="upsellOtherAmount">
|
|
58
55
|
<div class="upsellOtherAmountLabel">
|
|
59
56
|
<p>
|
|
60
|
-
${
|
|
57
|
+
${other}
|
|
61
58
|
</p>
|
|
62
59
|
</div>
|
|
63
60
|
<div class="upsellOtherAmountInput">
|
|
@@ -140,7 +137,7 @@ export class UpsellLightbox {
|
|
|
140
137
|
var _a, _b;
|
|
141
138
|
const value = parseFloat((_b = (_a = this.overlay.querySelector("#secondOtherField")) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : "");
|
|
142
139
|
const live_upsell_amount = document.querySelectorAll("#upsellYesButton .upsell_suggestion");
|
|
143
|
-
const upsellAmount = this.
|
|
140
|
+
const { amount: upsellAmount } = this.resolveUpsell();
|
|
144
141
|
if (!isNaN(value) && value > 0) {
|
|
145
142
|
this.checkOtherAmount(value);
|
|
146
143
|
}
|
|
@@ -152,59 +149,87 @@ export class UpsellLightbox {
|
|
|
152
149
|
liveAmounts() {
|
|
153
150
|
const live_upsell_amount = document.querySelectorAll(".upsell_suggestion");
|
|
154
151
|
const live_amount = document.querySelectorAll(".upsell_amount");
|
|
155
|
-
const upsellAmount = this.
|
|
152
|
+
const { amount: upsellAmount } = this.resolveUpsell();
|
|
156
153
|
const suggestedAmount = upsellAmount + this._fees.calculateFees(upsellAmount);
|
|
157
154
|
live_upsell_amount.forEach((elem) => (elem.innerHTML = this.getAmountTxt(suggestedAmount)));
|
|
158
155
|
live_amount.forEach((elem) => (elem.innerHTML = this.getAmountTxt(this._amount.amount + this._fees.fee)));
|
|
159
156
|
}
|
|
160
157
|
liveFrequency() {
|
|
161
158
|
const live_upsell_frequency = document.querySelectorAll(".upsell_frequency");
|
|
159
|
+
const live_upsell_suggestion_frequency = document.querySelectorAll(".upsell_suggestion_frequency");
|
|
162
160
|
live_upsell_frequency.forEach((elem) => (elem.innerHTML = this.getFrequencyTxt()));
|
|
161
|
+
live_upsell_suggestion_frequency.forEach((elem) => (elem.innerHTML = this.getFrequencyTxt(this._upsellFrequency)));
|
|
163
162
|
}
|
|
164
|
-
//
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
// Resolve the upsell amount and target frequency in a single pass and keep
|
|
164
|
+
// the cached _suggestAmount / _upsellFrequency in sync with the current
|
|
165
|
+
// donation amount and any value entered in the "other amount" field.
|
|
166
|
+
resolveUpsell() {
|
|
167
|
+
var _a, _b, _c, _d, _e;
|
|
167
168
|
const amount = this._amount.amount;
|
|
168
169
|
const otherAmount = parseFloat((_b = (_a = this.overlay.querySelector("#secondOtherField")) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : "");
|
|
170
|
+
const defaultFrequency = (_c = this.options.upsellToFrequency) !== null && _c !== void 0 ? _c : "monthly";
|
|
171
|
+
let upsellAmount;
|
|
172
|
+
let upsellFrequency;
|
|
169
173
|
if (otherAmount > 0) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
174
|
+
// An "other" amount overrides the amount but keeps the frequency that
|
|
175
|
+
// was already shown when the lightbox opened
|
|
176
|
+
upsellAmount =
|
|
177
|
+
otherAmount > this.options.minAmount
|
|
178
|
+
? otherAmount
|
|
179
|
+
: this.options.minAmount;
|
|
180
|
+
upsellFrequency = this._upsellFrequency;
|
|
173
181
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if (upsellAmount
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
else {
|
|
183
|
+
upsellAmount = 0;
|
|
184
|
+
upsellFrequency = defaultFrequency;
|
|
185
|
+
for (let i = 0; i < this.options.amountRange.length; i++) {
|
|
186
|
+
const val = this.options.amountRange[i];
|
|
187
|
+
if (upsellAmount == 0 && amount <= val.max) {
|
|
188
|
+
if (val.suggestion === 0) {
|
|
189
|
+
upsellFrequency = (_d = val.frequency) !== null && _d !== void 0 ? _d : defaultFrequency;
|
|
190
|
+
this._suggestAmount = 0;
|
|
191
|
+
this._upsellFrequency = upsellFrequency;
|
|
192
|
+
return { amount: 0, frequency: upsellFrequency };
|
|
193
|
+
}
|
|
194
|
+
else if (typeof val.suggestion === "number") {
|
|
195
|
+
upsellAmount = val.suggestion;
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
const suggestionMath = val.suggestion.replace("amount", amount.toFixed(2));
|
|
199
|
+
upsellAmount = parseFloat(Function('"use strict";return (' + suggestionMath + ")")());
|
|
200
|
+
}
|
|
201
|
+
upsellFrequency = (_e = val.frequency) !== null && _e !== void 0 ? _e : defaultFrequency;
|
|
202
|
+
break;
|
|
184
203
|
}
|
|
185
|
-
break;
|
|
186
204
|
}
|
|
205
|
+
upsellAmount =
|
|
206
|
+
upsellAmount > this.options.minAmount
|
|
207
|
+
? upsellAmount
|
|
208
|
+
: this.options.minAmount;
|
|
187
209
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
210
|
+
this._suggestAmount = upsellAmount;
|
|
211
|
+
this._upsellFrequency = upsellFrequency;
|
|
212
|
+
return { amount: upsellAmount, frequency: upsellFrequency };
|
|
191
213
|
}
|
|
192
214
|
shouldOpen() {
|
|
193
|
-
const upsellAmount = this.
|
|
215
|
+
const { amount: upsellAmount, frequency: upsellFrequency } = this.resolveUpsell();
|
|
194
216
|
const paymenttype = ENGrid.getFieldValue("transaction.paymenttype") || "";
|
|
195
|
-
|
|
196
|
-
//
|
|
197
|
-
//
|
|
198
|
-
//
|
|
217
|
+
// If frequency is not allowed, or
|
|
218
|
+
// the modal is already opened, or
|
|
219
|
+
// there's no suggestion for this donation amount, or
|
|
220
|
+
// the target upsell frequency is not available on the form,
|
|
199
221
|
// we should not open
|
|
200
222
|
if (this.freqAllowed() &&
|
|
201
223
|
!this.shouldSkip() &&
|
|
202
224
|
!this.options.disablePaymentMethods.includes(paymenttype.toLowerCase()) &&
|
|
203
225
|
!this.overlay.classList.contains("is-submitting") &&
|
|
204
|
-
upsellAmount > 0
|
|
226
|
+
upsellAmount > 0 &&
|
|
227
|
+
this._frequency.frequencies.includes(upsellFrequency) &&
|
|
228
|
+
this._frequency.frequency !== upsellFrequency) {
|
|
205
229
|
this.logger.log("Upsell Frequency " + this._frequency.frequency);
|
|
206
230
|
this.logger.log("Upsell Amount " + this._amount.amount);
|
|
207
231
|
this.logger.log("Upsell Suggested Amount " + upsellAmount);
|
|
232
|
+
this.logger.log("Upsell Suggested Frequency " + upsellFrequency);
|
|
208
233
|
return true;
|
|
209
234
|
}
|
|
210
235
|
return false;
|
|
@@ -215,6 +240,8 @@ export class UpsellLightbox {
|
|
|
215
240
|
const allowed = [];
|
|
216
241
|
if (this.options.oneTime)
|
|
217
242
|
allowed.push("onetime");
|
|
243
|
+
if (this.options.monthly)
|
|
244
|
+
allowed.push("monthly");
|
|
218
245
|
if (this.options.annual)
|
|
219
246
|
allowed.push("annual");
|
|
220
247
|
return allowed.includes(freq);
|
|
@@ -274,27 +301,30 @@ export class UpsellLightbox {
|
|
|
274
301
|
((_a = document.querySelector("#upsellYesButton")) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
|
|
275
302
|
this.logger.success("Upsold");
|
|
276
303
|
this.setOriginalAmount(this._amount.amount.toString());
|
|
277
|
-
const upsoldAmount = this.
|
|
304
|
+
const { amount: upsoldAmount, frequency: upsellFrequency } = this.resolveUpsell();
|
|
278
305
|
const originalAmount = this._amount.amount;
|
|
279
|
-
this._frequency.
|
|
306
|
+
const originalFrequency = this._frequency.frequency;
|
|
307
|
+
this._frequency.setFrequency(upsellFrequency);
|
|
280
308
|
this._amount.setAmount(upsoldAmount);
|
|
281
309
|
this._dataLayer.addEndOfGiftProcessEvent("ENGRID_UPSELL", {
|
|
282
310
|
eventValue: true,
|
|
311
|
+
originalFrequency: originalFrequency,
|
|
283
312
|
originalAmount: originalAmount,
|
|
284
313
|
upsoldAmount: upsoldAmount,
|
|
285
|
-
frequency:
|
|
314
|
+
frequency: upsellFrequency,
|
|
286
315
|
});
|
|
287
316
|
this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL", true);
|
|
288
317
|
this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_ORIGINAL_AMOUNT", originalAmount);
|
|
289
|
-
this._dataLayer.addEndOfGiftProcessVariable("
|
|
290
|
-
this.
|
|
318
|
+
this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_ORIGINAL_FREQUENCY", this.getFrequencyTxt(originalFrequency).toUpperCase());
|
|
319
|
+
this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_DONATION_FREQUENCY", this.getFrequencyTxt(upsellFrequency).toUpperCase());
|
|
320
|
+
this.renderConversionField("upsellSuccess", originalFrequency, originalAmount, upsellFrequency, this._suggestAmount, upsellFrequency, upsoldAmount);
|
|
291
321
|
}
|
|
292
322
|
else {
|
|
293
323
|
this.setOriginalAmount("");
|
|
294
324
|
window.sessionStorage.removeItem("original");
|
|
295
325
|
this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL", false);
|
|
296
|
-
this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_DONATION_FREQUENCY",
|
|
297
|
-
this.renderConversionField("upsellFail", this._frequency.frequency, this._amount.amount,
|
|
326
|
+
this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_DONATION_FREQUENCY", this.getFrequencyTxt(this._frequency.frequency).toUpperCase());
|
|
327
|
+
this.renderConversionField("upsellFail", this._frequency.frequency, this._amount.amount, this._upsellFrequency, this._suggestAmount, this._frequency.frequency, this._amount.amount);
|
|
298
328
|
}
|
|
299
329
|
this._form.submitForm();
|
|
300
330
|
}
|
|
@@ -304,7 +334,7 @@ export class UpsellLightbox {
|
|
|
304
334
|
this.overlay.classList.add("is-hidden");
|
|
305
335
|
ENGrid.setBodyData("has-lightbox", false);
|
|
306
336
|
if (this.options.submitOnClose) {
|
|
307
|
-
this.renderConversionField("upsellFail", this._frequency.frequency, this._amount.amount,
|
|
337
|
+
this.renderConversionField("upsellFail", this._frequency.frequency, this._amount.amount, this._upsellFrequency, this._suggestAmount, this._frequency.frequency, this._amount.amount);
|
|
308
338
|
this._form.submitForm();
|
|
309
339
|
}
|
|
310
340
|
else {
|
|
@@ -320,14 +350,16 @@ export class UpsellLightbox {
|
|
|
320
350
|
const amountTxt = ENGrid.formatNumber(amount, dec_places, dec_separator, thousands_separator);
|
|
321
351
|
return amount > 0 ? symbol + amountTxt : "";
|
|
322
352
|
}
|
|
323
|
-
getFrequencyTxt() {
|
|
353
|
+
getFrequencyTxt(frequency = this._frequency.frequency) {
|
|
324
354
|
const freqTxt = {
|
|
325
355
|
onetime: "one-time",
|
|
326
356
|
monthly: "monthly",
|
|
357
|
+
quarterly: "quarterly",
|
|
358
|
+
semi_annual: "semi-annual",
|
|
327
359
|
annual: "annual",
|
|
328
360
|
};
|
|
329
|
-
const
|
|
330
|
-
return
|
|
361
|
+
const freq = frequency;
|
|
362
|
+
return freq in freqTxt ? freqTxt[freq] : frequency;
|
|
331
363
|
}
|
|
332
364
|
checkOtherAmount(value) {
|
|
333
365
|
const otherInput = document.querySelector(".upsellOtherAmountInput");
|
|
@@ -343,7 +375,7 @@ export class UpsellLightbox {
|
|
|
343
375
|
renderConversionField(event, // The event that triggered the conversion
|
|
344
376
|
freq, // The frequency of the donation (onetime, monthly, annual)
|
|
345
377
|
amt, // The original amount of the donation (before the upsell)
|
|
346
|
-
sugFreq, // The suggested frequency of the upsell
|
|
378
|
+
sugFreq, // The suggested frequency of the upsell
|
|
347
379
|
sugAmt, // The suggested amount of the upsell
|
|
348
380
|
subFreq, // The submitted frequency of the upsell (onetime, monthly, annual)
|
|
349
381
|
subAmt // The submitted amount of the upsell
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AppVersion = "0.27.
|
|
1
|
+
export declare const AppVersion = "0.27.2";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AppVersion = "0.27.
|
|
1
|
+
export const AppVersion = "0.27.2";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4site/engrid-scripts",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.2",
|
|
4
4
|
"description": "Scripts for the ENGRID Project",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"strongly-typed-events": "^2.0.9"
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/4site-interactive-studios/engrid#readme",
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "12d807e7827704b485c0ce1b99e81b1e957362e8",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"nodemon": "^2.0.20"
|
|
31
31
|
}
|