@ordergroove/offers 2.27.2-alpha-PR-637-2.10 → 2.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/CHANGELOG.md +11 -0
- package/dist/bundle-report.html +9 -9
- package/dist/offers.js +27 -27
- package/dist/offers.js.map +2 -2
- package/package.json +2 -2
- package/src/components/Offer.js +4 -7
- package/src/components/Price.js +3 -25
- package/src/components/__tests__/Offer.spec.js +0 -29
- package/src/components/__tests__/Price.fspec.js +0 -32
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ordergroove/offers",
|
|
3
|
-
"version": "2.27.2
|
|
3
|
+
"version": "2.27.2",
|
|
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.12"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "c6a7ff6467e3ffd147fe1160b0944ee810146d5b"
|
|
49
49
|
}
|
package/src/components/Offer.js
CHANGED
|
@@ -44,9 +44,6 @@ export class Offer extends TemplateElement {
|
|
|
44
44
|
offerId: { type: String, attribute: false },
|
|
45
45
|
auth: authProp,
|
|
46
46
|
preview: { type: String, attribute: 'preview', reflect: 'true' },
|
|
47
|
-
previewRegularPrice: { type: String, attribute: 'preview-regular-price', reflect: 'true' },
|
|
48
|
-
previewDiscountRate: { type: String, attribute: 'preview-discount-rate', reflect: 'true' },
|
|
49
|
-
previewSubscriptionPrice: { type: String, attribute: 'preview-subscription-price', reflect: 'true' },
|
|
50
47
|
location: { type: String },
|
|
51
48
|
autoshipByDefault: { type: Boolean, attribute: 'autoship-by-default' },
|
|
52
49
|
productDefaultFrequency: { type: String, attribute: false },
|
|
@@ -152,11 +149,11 @@ export class Offer extends TemplateElement {
|
|
|
152
149
|
<og-price discount>
|
|
153
150
|
<span slot="prepend">Subscribe and get</span>
|
|
154
151
|
<span slot="append">off</span>
|
|
155
|
-
<og-text key="offerOptInLabel" slot="fallback"></og-text>
|
|
152
|
+
<og-text key="offerOptInLabel" slot="fallback"></og-text>
|
|
156
153
|
</og-price>
|
|
157
154
|
<og-price regular></og-price>
|
|
158
155
|
<og-price subscription></og-price>
|
|
159
|
-
|
|
156
|
+
|
|
160
157
|
</og-optin-button>
|
|
161
158
|
<og-tooltip placement="bottom">
|
|
162
159
|
<div slot="trigger">
|
|
@@ -220,7 +217,7 @@ export class Offer extends TemplateElement {
|
|
|
220
217
|
The product is in your next upcomming order
|
|
221
218
|
</og-when>
|
|
222
219
|
</og-when>
|
|
223
|
-
|
|
220
|
+
|
|
224
221
|
`;
|
|
225
222
|
}
|
|
226
223
|
|
|
@@ -302,7 +299,7 @@ export class Offer extends TemplateElement {
|
|
|
302
299
|
}
|
|
303
300
|
|
|
304
301
|
get isPreview() {
|
|
305
|
-
return this.preview;
|
|
302
|
+
return this.preview || window.og.previewMode;
|
|
306
303
|
}
|
|
307
304
|
|
|
308
305
|
render() {
|
package/src/components/Price.js
CHANGED
|
@@ -24,41 +24,19 @@ export class Price extends withProduct(TemplateElement) {
|
|
|
24
24
|
const frequency = this.frequency || this.configDefaultFrequency || this.offer?.defaultFrequency;
|
|
25
25
|
const plans = this.productPlans[realProductId] || {};
|
|
26
26
|
const currentPlan = plans[frequency] || [];
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
let [regularPrice, discountRate, subscriptionPrice] = currentPlan;
|
|
30
|
-
|
|
31
|
-
if (this.offer?.isPreview) {
|
|
32
|
-
if (this.offer?.previewRegularPrice) {
|
|
33
|
-
regularPrice = this.offer?.previewRegularPrice;
|
|
34
|
-
hasFakePreviewPrice = true;
|
|
35
|
-
}
|
|
36
|
-
if (this.offer?.previewDiscountRate) {
|
|
37
|
-
discountRate = this.offer?.previewDiscountRate;
|
|
38
|
-
hasFakePreviewPrice = true;
|
|
39
|
-
}
|
|
40
|
-
if (this.offer?.previewSubscriptionPrice) {
|
|
41
|
-
subscriptionPrice = this.offer?.previewSubscriptionPrice;
|
|
42
|
-
hasFakePreviewPrice = true;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (!currentPlan && !hasFakePreviewPrice) return '';
|
|
27
|
+
if (!currentPlan) return '';
|
|
28
|
+
const [regularPrice, discountRate, subscriptionPrice] = currentPlan;
|
|
47
29
|
if (subscriptionPrice === regularPrice) return '';
|
|
48
30
|
|
|
49
31
|
if (this.regular) {
|
|
50
32
|
return regularPrice;
|
|
51
33
|
}
|
|
52
|
-
if (this.discount)
|
|
53
|
-
return discountRate;
|
|
54
|
-
}
|
|
55
|
-
|
|
34
|
+
if (this.discount) return discountRate;
|
|
56
35
|
return subscriptionPrice;
|
|
57
36
|
}
|
|
58
37
|
|
|
59
38
|
render() {
|
|
60
39
|
const value = this.value;
|
|
61
|
-
|
|
62
40
|
if (value)
|
|
63
41
|
return html`
|
|
64
42
|
<slot name="prepend"></slot>
|
|
@@ -301,33 +301,4 @@ describe('previewMode', () => {
|
|
|
301
301
|
await el.updateComplete;
|
|
302
302
|
expect(el.preview).toEqual('upsell');
|
|
303
303
|
});
|
|
304
|
-
|
|
305
|
-
describe('preview values', () => {
|
|
306
|
-
it('should be compatible with preview-regular-price', async () => {
|
|
307
|
-
const el = document.createElement('og-offer');
|
|
308
|
-
el.setAttribute('preview-standard-offer', true);
|
|
309
|
-
el.setAttribute('preview-regular-price', 'mock-regular-price');
|
|
310
|
-
document.body.appendChild(el);
|
|
311
|
-
await el.updateComplete;
|
|
312
|
-
expect(el.previewRegularPrice).toEqual('mock-regular-price');
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
it('should be compatible with preview-discount-price', async () => {
|
|
316
|
-
const el = document.createElement('og-offer');
|
|
317
|
-
el.setAttribute('preview-standard-offer', true);
|
|
318
|
-
el.setAttribute('preview-discount-rate', 'mock-discount-rate');
|
|
319
|
-
document.body.appendChild(el);
|
|
320
|
-
await el.updateComplete;
|
|
321
|
-
expect(el.previewDiscountRate).toEqual('mock-discount-rate');
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
it('should be compatible with preview-subscription-price', async () => {
|
|
325
|
-
const el = document.createElement('og-offer');
|
|
326
|
-
el.setAttribute('preview-standard-offer', true);
|
|
327
|
-
el.setAttribute('preview-subscription-price', 'mock-subscription-price');
|
|
328
|
-
document.body.appendChild(el);
|
|
329
|
-
await el.updateComplete;
|
|
330
|
-
expect(el.previewSubscriptionPrice).toEqual('mock-subscription-price');
|
|
331
|
-
});
|
|
332
|
-
});
|
|
333
304
|
});
|
|
@@ -41,35 +41,3 @@ describe('Select Frequency', function() {
|
|
|
41
41
|
expect(htmlSelectElement.innerText).toEqual('Buy one time\n2 weeks (recomended)\n1 month');
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
|
-
|
|
45
|
-
describe('Preview Values', () => {
|
|
46
|
-
it('should render preview values if preview mode is enabled', async () => {
|
|
47
|
-
og.offers.clear();
|
|
48
|
-
document.body.innerHTML = `
|
|
49
|
-
<og-offer product="123" preview="regular" id="regular1" preview-regular-price="5.00" preview-discount-rate="10%" preview-subscription-price="$4.00"></og-offer>
|
|
50
|
-
`;
|
|
51
|
-
const element = document.querySelector('og-offer');
|
|
52
|
-
await element.updateComplete;
|
|
53
|
-
expect(
|
|
54
|
-
element.querySelector('og-optin-button og-price[regular]').shadowRoot.textContent.indexOf('5.00') !== -1
|
|
55
|
-
).toBe(true);
|
|
56
|
-
expect(
|
|
57
|
-
element.querySelector('og-optin-button og-price[discount]').shadowRoot.textContent.indexOf('10%') !== -1
|
|
58
|
-
).toBe(true);
|
|
59
|
-
expect(
|
|
60
|
-
element.querySelector('og-optin-button og-price[subscription]').shadowRoot.textContent.indexOf('$4.00') !== -1
|
|
61
|
-
).toBe(true);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('should render not preview values if preview values is not set', async () => {
|
|
65
|
-
og.offers.clear();
|
|
66
|
-
document.body.innerHTML = `
|
|
67
|
-
<og-offer product="123" preview="regular" id="regular1" ></og-offer>
|
|
68
|
-
`;
|
|
69
|
-
const element = document.querySelector('og-offer');
|
|
70
|
-
await element.updateComplete;
|
|
71
|
-
expect(element.querySelector('og-optin-button og-price[regular]').shadowRoot.textContent.trim()).toEqual('');
|
|
72
|
-
expect(element.querySelector('og-optin-button og-price[discount]').shadowRoot.textContent.trim()).toEqual('');
|
|
73
|
-
expect(element.querySelector('og-optin-button og-price[subscription]').shadowRoot.textContent.trim()).toEqual('');
|
|
74
|
-
});
|
|
75
|
-
});
|