@ordergroove/offers 2.27.5 → 2.27.8-alpha-PR-645-3.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ordergroove/offers",
3
- "version": "2.27.5",
3
+ "version": "2.27.8-alpha-PR-645-3.23+efeed72b",
4
4
  "description": "offer state component",
5
5
  "author": "Eugenio Lattanzio <eugenio63@gmail.com>",
6
6
  "homepage": "https://github.com/ordergroove/plush-toys#readme",
@@ -43,7 +43,7 @@
43
43
  "throttle-debounce": "^2.1.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@ordergroove/offers-templates": "^0.4.12"
46
+ "@ordergroove/offers-templates": "^0.4.13"
47
47
  },
48
- "gitHead": "94198fa4700e72ccc900f2c5707f2cff401e8360"
48
+ "gitHead": "efeed72be5202336030275f57b21de6ab8245c31"
49
49
  }
@@ -31,8 +31,14 @@ export class OptinSelect extends withChildOptions(OptinStatus) {
31
31
  `;
32
32
  }
33
33
 
34
- get isSelected() {
35
- return this.subscribed ? this.frequency : 'optedOut';
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, isSelected } = this.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 = childOptions;
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="${isSelected}"
86
+ .selected="${this.currentFrequency}"
73
87
  .onChange="${({ target: { value } }) => this.onOptinChange(value)}"
74
88
  ></og-select>
75
89
  `;
@@ -299,7 +299,7 @@ function synchronizeSellingPlan(store: any, offerElement?: HTMLElement) {
299
299
  }
300
300
 
301
301
  export default function shopifyMiddleware(store) {
302
- return next => action => {
302
+ return next => async action => {
303
303
  /**
304
304
  * This redux middleware will perform Shopify specific side-effects such as change
305
305
  * the product selling plan when offer is cart
@@ -313,7 +313,8 @@ export default function shopifyMiddleware(store) {
313
313
  if (action.payload.offer?.isCart) {
314
314
  setupCart(store, action.payload.offer);
315
315
  } else {
316
- setupPdp(store, action.payload.offer);
316
+ //await so that RECEIVE_OFFER will have selling plan id available and doesn't use OG frequency
317
+ await setupPdp(store, action.payload.offer);
317
318
  }
318
319
  default:
319
320
  }