@ordergroove/offers 2.27.6 → 2.27.8-alpha-PR-646-1.22
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/CHANGELOG.md +8 -0
- package/dist/bundle-report.html +10 -10
- package/dist/offers.js +51 -49
- package/dist/offers.js.map +2 -2
- package/package.json +2 -2
- package/src/components/OptinSelect.js +19 -5
- package/src/shopify/shopifyMiddleware.ts +12 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ordergroove/offers",
|
|
3
|
-
"version": "2.27.
|
|
3
|
+
"version": "2.27.8-alpha-PR-646-1.22+71bf566b",
|
|
4
4
|
"description": "offer state component",
|
|
5
5
|
"author": "Eugenio Lattanzio <eugenio63@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/ordergroove/plush-toys#readme",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@ordergroove/offers-templates": "^0.4.13"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "71bf566bafea5781f2a883b6d499057aef1b33ca"
|
|
49
49
|
}
|
|
@@ -31,8 +31,14 @@ export class OptinSelect extends withChildOptions(OptinStatus) {
|
|
|
31
31
|
`;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
get
|
|
35
|
-
|
|
34
|
+
get currentFrequency() {
|
|
35
|
+
if (!this.subscribed) {
|
|
36
|
+
return 'optedOut';
|
|
37
|
+
}
|
|
38
|
+
if (this.frequency) {
|
|
39
|
+
return this.frequency;
|
|
40
|
+
}
|
|
41
|
+
return this.defaultFrequency;
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
onOptinChange(value) {
|
|
@@ -44,7 +50,7 @@ export class OptinSelect extends withChildOptions(OptinStatus) {
|
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
render() {
|
|
47
|
-
const { options: childOptions
|
|
53
|
+
const { options: childOptions } = this.childOptions;
|
|
48
54
|
let options;
|
|
49
55
|
if (this.frequencies?.length) {
|
|
50
56
|
options = [
|
|
@@ -63,13 +69,21 @@ export class OptinSelect extends withChildOptions(OptinStatus) {
|
|
|
63
69
|
}))
|
|
64
70
|
];
|
|
65
71
|
} else {
|
|
66
|
-
options =
|
|
72
|
+
options = [
|
|
73
|
+
{
|
|
74
|
+
value: 'optedOut',
|
|
75
|
+
text: html`
|
|
76
|
+
<og-text key="offerOptOutLabel"></og-text>
|
|
77
|
+
`
|
|
78
|
+
},
|
|
79
|
+
...childOptions
|
|
80
|
+
];
|
|
67
81
|
}
|
|
68
82
|
|
|
69
83
|
return html`
|
|
70
84
|
<og-select
|
|
71
85
|
.options="${options}"
|
|
72
|
-
.selected="${
|
|
86
|
+
.selected="${this.currentFrequency}"
|
|
73
87
|
.onChange="${({ target: { value } }) => this.onOptinChange(value)}"
|
|
74
88
|
></og-select>
|
|
75
89
|
`;
|
|
@@ -34,11 +34,19 @@ async function setupPdp(store, offer) {
|
|
|
34
34
|
console.warn('OG: Unable to fetch product details for PDP', err);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
|
|
38
37
|
const form = offer.closest('form');
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
if (form) {
|
|
39
|
+
const mo = new MutationObserver(() => syncProductId(form, offer));
|
|
40
|
+
mo.observe(form, { subtree: true, childList: true });
|
|
41
|
+
} else {
|
|
42
|
+
for (let it of document.querySelectorAll('form[action="/cart/add"] [name=id]')) {
|
|
43
|
+
const input = it as HTMLFormElement;
|
|
44
|
+
if (input.getAttribute('value') === offer.getAttribute('product')) {
|
|
45
|
+
const mo = new MutationObserver(() => syncProductId(input.form, offer));
|
|
46
|
+
mo.observe(input.form, { subtree: true, childList: true });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
42
50
|
}
|
|
43
51
|
|
|
44
52
|
const getCart = async () => await (await fetch(CART_JS_URL)).json();
|