wickes-css2 2.112.0-develop.6 → 2.112.0-develop.8
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/Readme.md +1 -1
- package/build/css/pdp-main-before-combine.css +1 -1
- package/build/css/pdp-main-non-critical.css +1 -1
- package/build/css/pdp-main.css +1 -1
- package/build/js/bloomreach-widget.min.js +1 -1
- package/build/js/emulation.min.js +334 -8
- package/build/js/page/bloomreach-widget/bloomreach-widget.js +250 -0
- package/build/js/page/{bloomreach-widget.js → bloomreach-widget/complete-your-project-widget.js} +205 -359
- package/build/js/page/bloomreach-widget/why-not-add-widget.js +198 -0
- package/package.json +1 -5
- package/src/components/bloomreach/complete-card.hbs +4 -32
- package/src/components/bloomreach/why-not-add-card-skeleton.hbs +14 -0
- package/src/components/bloomreach/why-not-add-card.hbs +73 -0
- package/src/components/bloomreach/why-not-add-content.hbs +41 -0
- package/src/components/bloomreach/why-not-add-skeleton.hbs +9 -0
- package/src/components/bloomreach/why-not-add.hbs +6 -0
- package/src/components/pdp-price-actions.hbs +2 -2
- package/src/components/price-block-v2.hbs +2 -0
- package/src/components/reviews-rating.hbs +22 -0
- package/src/components/share-list-modal-without-social-icons.hbs +1 -1
- package/src/components/share-list-modal.hbs +1 -1
- package/src/js/emulation/bloomreach-widget-loading.js +2 -2
- package/src/js/emulation/mock.js +309 -0
- package/src/js/emulation/why-not-add-loading.js +11 -0
- package/src/js/emulation/why-not-add.js +28 -0
- package/src/js/page/bloomreach-widget/bloomreach-widget.js +250 -0
- package/src/js/page/{bloomreach-widget.js → bloomreach-widget/complete-your-project-widget.js} +205 -359
- package/src/js/page/bloomreach-widget/why-not-add-widget.js +198 -0
- package/src/page_product-details-bloomreach.html +1 -1
- package/src/page_product-details-with-global-search-v2.html +2 -1
- package/src/page_product-details-with-why-not-add-single.html +131 -0
- package/src/scss/components/bloomreach/_bloomreach.scss +3 -0
- package/src/scss/components/bloomreach/_complete-card.scss +0 -38
- package/src/scss/components/bloomreach/_reviews.scss +60 -0
- package/src/scss/components/bloomreach/_why-not-add-card.scss +223 -0
- package/src/scss/components/bloomreach/_why-not-add.scss +143 -0
- package/src/sitemap.html +10 -4
package/src/js/emulation/mock.js
CHANGED
|
@@ -9,6 +9,315 @@ Wick.FEMock = {
|
|
|
9
9
|
);
|
|
10
10
|
},
|
|
11
11
|
dataBloomreach: {
|
|
12
|
+
whyNotAddRecommendationsSingle: {
|
|
13
|
+
recommendedProducts: [
|
|
14
|
+
{
|
|
15
|
+
baseProduct: {
|
|
16
|
+
code: '153731',
|
|
17
|
+
name: 'Wickes Trade Paint Roller Set - 9in',
|
|
18
|
+
url: '/Wickes-Trade-Paint-Roller-Set---9in/p/153731',
|
|
19
|
+
purchasable: true,
|
|
20
|
+
productType: 'ProductModel',
|
|
21
|
+
isBaseProduct: false,
|
|
22
|
+
availabilityRestriction: 'NO_RESTRICTIONS',
|
|
23
|
+
fulfilmentType: 'STANDARD',
|
|
24
|
+
stock: {
|
|
25
|
+
stockLevelStatus: {
|
|
26
|
+
code: 'inStock',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
fulfillmentAttributes: {
|
|
30
|
+
type: 'STANDARD',
|
|
31
|
+
},
|
|
32
|
+
images: [
|
|
33
|
+
{
|
|
34
|
+
imageType: 'PRIMARY',
|
|
35
|
+
format: 'product',
|
|
36
|
+
url: 'https://placehold.co/68x68?text=roller',
|
|
37
|
+
altText: 'Wickes Trade Paint Roller Set - 9in',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
externalAverageRating: 5,
|
|
41
|
+
externalReviewCount: 100,
|
|
42
|
+
displayPrice: {
|
|
43
|
+
currencyIso: 'GBP',
|
|
44
|
+
value: 9999,
|
|
45
|
+
priceType: 'BUY',
|
|
46
|
+
formattedValue: '£9,999.00',
|
|
47
|
+
formattedPriceWithoutCurrencySymbol: '16',
|
|
48
|
+
currencySymbol: '£',
|
|
49
|
+
vatRatePercentage: 20,
|
|
50
|
+
valueInPence: 999900,
|
|
51
|
+
wasPrice: 30,
|
|
52
|
+
},
|
|
53
|
+
displayPriceExclusiveVat: {
|
|
54
|
+
currencyIso: 'GBP',
|
|
55
|
+
value: 9998,
|
|
56
|
+
priceType: 'BUY',
|
|
57
|
+
formattedValue: '£9,998.00',
|
|
58
|
+
formattedPriceWithoutCurrencySymbol: '13.33',
|
|
59
|
+
currencySymbol: '£',
|
|
60
|
+
valueInPence: 999800,
|
|
61
|
+
wasPrice: 25,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
whyNotAddRecommendations: {
|
|
68
|
+
recommendedProducts: [
|
|
69
|
+
{
|
|
70
|
+
baseProduct: {
|
|
71
|
+
code: '153731',
|
|
72
|
+
name: 'Wickes Trade Paint Roller Set - 9in',
|
|
73
|
+
url: '/Wickes-Trade-Paint-Roller-Set---9in/p/153731',
|
|
74
|
+
purchasable: true,
|
|
75
|
+
productType: 'ProductModel',
|
|
76
|
+
isBaseProduct: false,
|
|
77
|
+
availabilityRestriction: 'NO_RESTRICTIONS',
|
|
78
|
+
fulfilmentType: 'STANDARD',
|
|
79
|
+
stock: {
|
|
80
|
+
stockLevelStatus: {
|
|
81
|
+
code: 'inStock',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
fulfillmentAttributes: {
|
|
85
|
+
type: 'STANDARD',
|
|
86
|
+
},
|
|
87
|
+
images: [
|
|
88
|
+
{
|
|
89
|
+
imageType: 'PRIMARY',
|
|
90
|
+
format: 'product',
|
|
91
|
+
url: 'https://placehold.co/68x68?text=roller',
|
|
92
|
+
altText: 'Wickes Trade Paint Roller Set - 9in',
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
externalAverageRating: 5,
|
|
96
|
+
externalReviewCount: 100,
|
|
97
|
+
|
|
98
|
+
displayPrice: {
|
|
99
|
+
currencyIso: 'GBP',
|
|
100
|
+
value: 9999,
|
|
101
|
+
priceType: 'BUY',
|
|
102
|
+
formattedValue: '£9,999.00',
|
|
103
|
+
formattedPriceWithoutCurrencySymbol: '16',
|
|
104
|
+
currencySymbol: '£',
|
|
105
|
+
vatRatePercentage: 20,
|
|
106
|
+
valueInPence: 999900,
|
|
107
|
+
wasPrice: 3000,
|
|
108
|
+
},
|
|
109
|
+
displayPriceExclusiveVat: {
|
|
110
|
+
currencyIso: 'GBP',
|
|
111
|
+
value: 9998,
|
|
112
|
+
priceType: 'BUY',
|
|
113
|
+
formattedValue: '£9,998.00',
|
|
114
|
+
formattedPriceWithoutCurrencySymbol: '13.33',
|
|
115
|
+
currencySymbol: '£',
|
|
116
|
+
valueInPence: 999800,
|
|
117
|
+
wasPrice: 2500,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
baseProduct: {
|
|
123
|
+
code: '349137',
|
|
124
|
+
name: 'Wickes Microfibre Paint Roller Sleeve - 9in',
|
|
125
|
+
url: '/Wickes-Microfibre-Paint-Roller-Sleeve---9in/p/349137',
|
|
126
|
+
purchasable: true,
|
|
127
|
+
productType: 'ProductModel',
|
|
128
|
+
isBaseProduct: false,
|
|
129
|
+
availabilityRestriction: 'NO_RESTRICTIONS',
|
|
130
|
+
fulfilmentType: 'STANDARD',
|
|
131
|
+
stock: {
|
|
132
|
+
stockLevelStatus: {
|
|
133
|
+
code: 'inStock',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
fulfillmentAttributes: {
|
|
137
|
+
type: 'STANDARD',
|
|
138
|
+
},
|
|
139
|
+
images: [
|
|
140
|
+
{
|
|
141
|
+
imageType: 'PRIMARY',
|
|
142
|
+
format: 'product',
|
|
143
|
+
url: 'https://placehold.co/68x68?text=sleeve',
|
|
144
|
+
altText: 'Wickes Microfibre Paint Roller Sleeve - 9in',
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
externalAverageRating: 4.2,
|
|
148
|
+
externalReviewCount: 48,
|
|
149
|
+
displayPrice: {
|
|
150
|
+
currencyIso: 'GBP',
|
|
151
|
+
value: 9999,
|
|
152
|
+
priceType: 'BUY',
|
|
153
|
+
formattedValue: '£7.5220',
|
|
154
|
+
formattedPriceWithoutCurrencySymbol: '7.50',
|
|
155
|
+
currencySymbol: '£',
|
|
156
|
+
vatRatePercentage: 20,
|
|
157
|
+
valueInPence: 999900,
|
|
158
|
+
},
|
|
159
|
+
displayPriceExclusiveVat: {
|
|
160
|
+
currencyIso: 'GBP',
|
|
161
|
+
value: 9998,
|
|
162
|
+
priceType: 'BUY',
|
|
163
|
+
formattedValue: '£6.25',
|
|
164
|
+
formattedPriceWithoutCurrencySymbol: '6.25',
|
|
165
|
+
currencySymbol: '£',
|
|
166
|
+
valueInPence: 999800,
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
baseProduct: {
|
|
172
|
+
code: '221048',
|
|
173
|
+
name: 'Wickes Paint Tray - 9in',
|
|
174
|
+
url: '/Wickes-Paint-Tray---9in/p/221048',
|
|
175
|
+
purchasable: true,
|
|
176
|
+
productType: 'ProductModel',
|
|
177
|
+
isBaseProduct: false,
|
|
178
|
+
availabilityRestriction: 'NO_RESTRICTIONS',
|
|
179
|
+
fulfilmentType: 'STANDARD',
|
|
180
|
+
stock: {
|
|
181
|
+
stockLevelStatus: {
|
|
182
|
+
code: 'inStock',
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
fulfillmentAttributes: {
|
|
186
|
+
type: 'STANDARD',
|
|
187
|
+
},
|
|
188
|
+
images: [
|
|
189
|
+
{
|
|
190
|
+
imageType: 'PRIMARY',
|
|
191
|
+
format: 'product',
|
|
192
|
+
url: 'https://placehold.co/68x68?text=tray',
|
|
193
|
+
altText: 'Wickes Paint Tray - 9in',
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
externalAverageRating: 3.8,
|
|
197
|
+
externalReviewCount: 19,
|
|
198
|
+
displayPrice: {
|
|
199
|
+
currencyIso: 'GBP',
|
|
200
|
+
value: 4,
|
|
201
|
+
priceType: 'BUY',
|
|
202
|
+
formattedValue: '£4',
|
|
203
|
+
formattedPriceWithoutCurrencySymbol: '4',
|
|
204
|
+
currencySymbol: '£',
|
|
205
|
+
vatRatePercentage: 20,
|
|
206
|
+
valueInPence: 400,
|
|
207
|
+
},
|
|
208
|
+
displayPriceExclusiveVat: {
|
|
209
|
+
currencyIso: 'GBP',
|
|
210
|
+
value: 3.33,
|
|
211
|
+
priceType: 'BUY',
|
|
212
|
+
formattedValue: '£3.33',
|
|
213
|
+
formattedPriceWithoutCurrencySymbol: '3.33',
|
|
214
|
+
currencySymbol: '£',
|
|
215
|
+
valueInPence: 333,
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
baseProduct: {
|
|
221
|
+
code: '654221',
|
|
222
|
+
name: 'Wickes Professional Masking Tape - 48mm x 50m',
|
|
223
|
+
url: '/Wickes-Professional-Masking-Tape---48mm-x-50m/p/654221',
|
|
224
|
+
purchasable: true,
|
|
225
|
+
productType: 'ProductModel',
|
|
226
|
+
isBaseProduct: false,
|
|
227
|
+
availabilityRestriction: 'NO_RESTRICTIONS',
|
|
228
|
+
fulfilmentType: 'STANDARD',
|
|
229
|
+
stock: {
|
|
230
|
+
stockLevelStatus: {
|
|
231
|
+
code: 'inStock',
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
fulfillmentAttributes: {
|
|
235
|
+
type: 'STANDARD',
|
|
236
|
+
},
|
|
237
|
+
images: [
|
|
238
|
+
{
|
|
239
|
+
imageType: 'PRIMARY',
|
|
240
|
+
format: 'product',
|
|
241
|
+
url: 'https://placehold.co/68x68?text=tape',
|
|
242
|
+
altText: 'Wickes Professional Masking Tape - 48mm x 50m',
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
externalAverageRating: 4.6,
|
|
246
|
+
externalReviewCount: 72,
|
|
247
|
+
displayPrice: {
|
|
248
|
+
currencyIso: 'GBP',
|
|
249
|
+
value: 5.5,
|
|
250
|
+
priceType: 'BUY',
|
|
251
|
+
formattedValue: '£5.50',
|
|
252
|
+
formattedPriceWithoutCurrencySymbol: '5.50',
|
|
253
|
+
currencySymbol: '£',
|
|
254
|
+
vatRatePercentage: 20,
|
|
255
|
+
valueInPence: 550,
|
|
256
|
+
},
|
|
257
|
+
displayPriceExclusiveVat: {
|
|
258
|
+
currencyIso: 'GBP',
|
|
259
|
+
value: 4.58,
|
|
260
|
+
priceType: 'BUY',
|
|
261
|
+
formattedValue: '£4.58',
|
|
262
|
+
formattedPriceWithoutCurrencySymbol: '4.58',
|
|
263
|
+
currencySymbol: '£',
|
|
264
|
+
valueInPence: 458,
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
baseProduct: {
|
|
270
|
+
code: '782913',
|
|
271
|
+
name: 'Wickes Dust Sheet Cotton Twill - 3.6m x 2.7m Extra Long Product Name For Two Line Truncation Test',
|
|
272
|
+
url: '/Wickes-Dust-Sheet-Cotton-Twill---3-6m-x-2-7m/p/782913',
|
|
273
|
+
purchasable: true,
|
|
274
|
+
productType: 'ProductModel',
|
|
275
|
+
isBaseProduct: false,
|
|
276
|
+
availabilityRestriction: 'NO_RESTRICTIONS',
|
|
277
|
+
fulfilmentType: 'STANDARD',
|
|
278
|
+
stock: {
|
|
279
|
+
stockLevelStatus: {
|
|
280
|
+
code: 'inStock',
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
fulfillmentAttributes: {
|
|
284
|
+
type: 'STANDARD',
|
|
285
|
+
},
|
|
286
|
+
images: [
|
|
287
|
+
{
|
|
288
|
+
imageType: 'PRIMARY',
|
|
289
|
+
format: 'product',
|
|
290
|
+
url: 'https://placehold.co/68x68?text=sheet',
|
|
291
|
+
altText: 'Wickes Dust Sheet Cotton Twill - 3.6m x 2.7m',
|
|
292
|
+
},
|
|
293
|
+
],
|
|
294
|
+
externalAverageRating: 4.1,
|
|
295
|
+
externalReviewCount: 34,
|
|
296
|
+
displayPrice: {
|
|
297
|
+
currencyIso: 'GBP',
|
|
298
|
+
value: 12,
|
|
299
|
+
priceType: 'BUY',
|
|
300
|
+
formattedValue: '£12',
|
|
301
|
+
formattedPriceWithoutCurrencySymbol: '12',
|
|
302
|
+
currencySymbol: '£',
|
|
303
|
+
vatRatePercentage: 20,
|
|
304
|
+
valueInPence: 1200,
|
|
305
|
+
wasPrice: 18,
|
|
306
|
+
},
|
|
307
|
+
displayPriceExclusiveVat: {
|
|
308
|
+
currencyIso: 'GBP',
|
|
309
|
+
value: 10,
|
|
310
|
+
priceType: 'BUY',
|
|
311
|
+
formattedValue: '£10',
|
|
312
|
+
formattedPriceWithoutCurrencySymbol: '10',
|
|
313
|
+
currencySymbol: '£',
|
|
314
|
+
valueInPence: 1000,
|
|
315
|
+
wasPrice: 15,
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
],
|
|
320
|
+
},
|
|
12
321
|
completeYourProject3Recomendations: [
|
|
13
322
|
{
|
|
14
323
|
baseProduct: {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var Wick = window.Wick || {};
|
|
2
|
+
|
|
3
|
+
$(document).ready(function () {
|
|
4
|
+
window.setTimeout(function () {
|
|
5
|
+
const $container = $('[data-why-not-add-widget]');
|
|
6
|
+
const mockDataKey = $container.data('mock-key');
|
|
7
|
+
const payloadData = Wick.FEMock.dataBloomreach[mockDataKey];
|
|
8
|
+
|
|
9
|
+
Wick.BloomreachWidget.init('whyNotAdd', payloadData);
|
|
10
|
+
}, 3000);
|
|
11
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var Wick = window.Wick || {};
|
|
2
|
+
|
|
3
|
+
function simulateHybrisSendingHtml() {
|
|
4
|
+
const htmlFromHybris = Wick.FEMock.cartPDP;
|
|
5
|
+
|
|
6
|
+
window.dispatchEvent(
|
|
7
|
+
new CustomEvent('productAddedToCart', {
|
|
8
|
+
detail: {
|
|
9
|
+
html: htmlFromHybris,
|
|
10
|
+
},
|
|
11
|
+
})
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function bindWhyNotAddToCartEvent() {
|
|
16
|
+
$(window)
|
|
17
|
+
.off('addToCart.whyNotAddEmulation')
|
|
18
|
+
.on('addToCart.whyNotAddEmulation', function ({ detail: { resolve } }) {
|
|
19
|
+
setTimeout(function () {
|
|
20
|
+
resolve();
|
|
21
|
+
simulateHybrisSendingHtml();
|
|
22
|
+
}, 3000);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
$(document).ready(function () {
|
|
27
|
+
bindWhyNotAddToCartEvent();
|
|
28
|
+
});
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
var Wick = window.Wick || {};
|
|
2
|
+
|
|
3
|
+
import { isApp } from '../utils/helpers';
|
|
4
|
+
import { createEvent } from '../utils/create-event';
|
|
5
|
+
import CompleteYourProjectWidget from './complete-your-project-widget';
|
|
6
|
+
import WhyNotAddWidget from './why-not-add-widget';
|
|
7
|
+
|
|
8
|
+
Wick.BloomreachWidget = {
|
|
9
|
+
widgets: {},
|
|
10
|
+
|
|
11
|
+
el: {
|
|
12
|
+
loadingButtonText: '.loading-button__text',
|
|
13
|
+
loadingButtonLoader: '.loading-button__loader',
|
|
14
|
+
ratingOverlay: '.rating-overlay',
|
|
15
|
+
starOverlay: '.star-overlay',
|
|
16
|
+
vatInc: '.including-vat-inherit',
|
|
17
|
+
vatExc: '.excluding-vat-inherit',
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
registerWidgets(widgetList) {
|
|
21
|
+
widgetList.forEach(function ({ type, widget }) {
|
|
22
|
+
Wick.BloomreachWidget.widgets[type] = widget;
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
getWidget(type) {
|
|
27
|
+
return Wick.BloomreachWidget.widgets[type];
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
init(type, payloadData) {
|
|
31
|
+
const widget = Wick.BloomreachWidget.getWidget(type);
|
|
32
|
+
|
|
33
|
+
if (!widget || typeof widget.init !== 'function') {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
widget.init(payloadData, Wick.BloomreachWidget);
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
normalizePayload(payloadData) {
|
|
41
|
+
if (Array.isArray(payloadData)) {
|
|
42
|
+
return payloadData;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (payloadData && Array.isArray(payloadData.recommendedProducts)) {
|
|
46
|
+
return payloadData.recommendedProducts;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return [];
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
hasRecommendations(payloadData) {
|
|
53
|
+
return Wick.BloomreachWidget.normalizePayload(payloadData).length > 0;
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
getDisplayPrice(product) {
|
|
57
|
+
return product.displayPrice || product.price || {};
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
getDisplayPriceExcVat(product) {
|
|
61
|
+
return product.displayPriceExclusiveVat || product.priceExclusiveVat || null;
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
getPriceValue(price) {
|
|
65
|
+
return price && typeof price.value === 'number' ? price.value : 0;
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
getPriceFormattedValue(price) {
|
|
69
|
+
if (!price) {
|
|
70
|
+
return '';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (price.formattedValue) {
|
|
74
|
+
return price.formattedValue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (typeof price.value === 'number') {
|
|
78
|
+
return Wick.BloomreachWidget.formatPrice(price.value);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return '';
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
removeBlankTargets($root) {
|
|
85
|
+
if (!isApp()) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
$root.find('a[target="_blank"]').removeAttr('target');
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
getWasPrice(product) {
|
|
93
|
+
const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
|
|
94
|
+
|
|
95
|
+
return displayPrice && displayPrice.wasPrice ? displayPrice.wasPrice : null;
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
getWasPriceFormatted(product) {
|
|
99
|
+
const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
|
|
100
|
+
const wasPrice = Wick.BloomreachWidget.getWasPrice(product);
|
|
101
|
+
|
|
102
|
+
if (wasPrice && wasPrice.formattedValue) {
|
|
103
|
+
return wasPrice.formattedValue;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (typeof wasPrice === 'number') {
|
|
107
|
+
return Wick.BloomreachWidget.formatPrice(wasPrice);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (wasPrice) {
|
|
111
|
+
return `${displayPrice.currencySymbol || '£'}${wasPrice}`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return '';
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
getExcVatWasPrice(product) {
|
|
118
|
+
const priceExclusiveVat = product.priceExclusiveVat || null;
|
|
119
|
+
const displayPriceExclusiveVat = product.displayPriceExclusiveVat || null;
|
|
120
|
+
const wasPrice =
|
|
121
|
+
(displayPriceExclusiveVat && displayPriceExclusiveVat.wasPrice) ||
|
|
122
|
+
(priceExclusiveVat && priceExclusiveVat.wasPrice);
|
|
123
|
+
|
|
124
|
+
if (wasPrice && wasPrice.formattedValue) {
|
|
125
|
+
return wasPrice.formattedValue;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (typeof wasPrice === 'number') {
|
|
129
|
+
return Wick.BloomreachWidget.formatPrice(wasPrice);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return wasPrice || '';
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
getProductImage(product, fallbackProduct) {
|
|
136
|
+
const productImages = product.images || [];
|
|
137
|
+
const fallbackImages = fallbackProduct ? fallbackProduct.images || [] : [];
|
|
138
|
+
const images = productImages.length ? productImages : fallbackImages;
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
images.find(function (item) {
|
|
142
|
+
return item.format === 'product';
|
|
143
|
+
}) ||
|
|
144
|
+
images.find(function (item) {
|
|
145
|
+
return item.imageType === 'PRIMARY';
|
|
146
|
+
}) ||
|
|
147
|
+
images[0] ||
|
|
148
|
+
{}
|
|
149
|
+
);
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
getProductRenderData(product, options = {}) {
|
|
153
|
+
const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
|
|
154
|
+
const displayPriceExcVat = Wick.BloomreachWidget.getDisplayPriceExcVat(product);
|
|
155
|
+
const wasPriceFormatted = Wick.BloomreachWidget.getWasPriceFormatted(product);
|
|
156
|
+
const excVatWasPriceFormatted = Wick.BloomreachWidget.getExcVatWasPrice(product);
|
|
157
|
+
const isSwitchVat = !!(window.ACC && window.ACC.app && window.ACC.app.isVatToggleAvailable);
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
...product,
|
|
161
|
+
price: displayPrice,
|
|
162
|
+
image:
|
|
163
|
+
options.image ||
|
|
164
|
+
Wick.BloomreachWidget.getProductImage(product, options.fallbackProduct),
|
|
165
|
+
wasPriceFormatted,
|
|
166
|
+
'switch-vat': isSwitchVat,
|
|
167
|
+
incVatFormattedValue: Wick.BloomreachWidget.getPriceFormattedValue(displayPrice),
|
|
168
|
+
incVatValue: Wick.BloomreachWidget.getPriceValue(displayPrice),
|
|
169
|
+
excVatFormattedValue: Wick.BloomreachWidget.getPriceFormattedValue(displayPriceExcVat),
|
|
170
|
+
excVatValue: Wick.BloomreachWidget.getPriceValue(displayPriceExcVat),
|
|
171
|
+
incVatWasPriceFormatted: wasPriceFormatted,
|
|
172
|
+
excVatWasPriceFormatted: Wick.BloomreachWidget.getExcVatWasPrice(product),
|
|
173
|
+
};
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
drawRating($root) {
|
|
177
|
+
const { ratingOverlay, starOverlay } = Wick.BloomreachWidget.el;
|
|
178
|
+
|
|
179
|
+
$root.find(ratingOverlay).each(function () {
|
|
180
|
+
let rating = parseFloat($(this).attr('data-rating')) || 0;
|
|
181
|
+
const $stars = $(this).children(starOverlay);
|
|
182
|
+
|
|
183
|
+
$stars.each(function () {
|
|
184
|
+
const $star = $(this);
|
|
185
|
+
|
|
186
|
+
if (rating >= 1) {
|
|
187
|
+
rating--;
|
|
188
|
+
} else if (rating > 0) {
|
|
189
|
+
const width = Math.asin(2 * rating - 1) / Math.PI + 0.5;
|
|
190
|
+
$star.css('width', width + 'rem');
|
|
191
|
+
rating = 0;
|
|
192
|
+
} else {
|
|
193
|
+
$star.css('width', '0rem');
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
dispatchWidgetEvent(eventName, payload) {
|
|
200
|
+
return new Promise(function (resolve, reject) {
|
|
201
|
+
const eventDetail = { resolve, reject };
|
|
202
|
+
const event = createEvent(eventName, payload, eventDetail);
|
|
203
|
+
|
|
204
|
+
window.dispatchEvent(event);
|
|
205
|
+
});
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
reapplyVatDisplay() {
|
|
209
|
+
if (!Wick.VatToggle || typeof Wick.VatToggle.isActive !== 'function') {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const { vatInc, vatExc } = Wick.BloomreachWidget.el;
|
|
214
|
+
const hiddenClassName = Wick.VatToggle.HIDDEN_CLASS_NAME || 'd-none';
|
|
215
|
+
const isExcVatActive = Wick.VatToggle.isActive();
|
|
216
|
+
|
|
217
|
+
$(vatInc).toggleClass(hiddenClassName, isExcVatActive);
|
|
218
|
+
$(vatExc).toggleClass(hiddenClassName, !isExcVatActive);
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
bindVatToggle(namespace) {
|
|
222
|
+
if (!Wick.VatToggle || !Wick.VatToggle.TOGGLE_VAT_EVENT_NAME) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const eventName = `${Wick.VatToggle.TOGGLE_VAT_EVENT_NAME}.${namespace}`;
|
|
227
|
+
|
|
228
|
+
$(window).off(eventName).on(eventName, Wick.BloomreachWidget.reapplyVatDisplay);
|
|
229
|
+
},
|
|
230
|
+
|
|
231
|
+
formatPrice(value) {
|
|
232
|
+
return new Intl.NumberFormat('en-GB', {
|
|
233
|
+
style: 'currency',
|
|
234
|
+
currency: 'GBP',
|
|
235
|
+
minimumFractionDigits: 2,
|
|
236
|
+
maximumFractionDigits: 2,
|
|
237
|
+
}).format(value);
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
Wick.BloomreachWidget.registerWidgets([
|
|
242
|
+
{
|
|
243
|
+
type: 'completeYourProject',
|
|
244
|
+
widget: CompleteYourProjectWidget,
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
type: 'whyNotAdd',
|
|
248
|
+
widget: WhyNotAddWidget,
|
|
249
|
+
},
|
|
250
|
+
]);
|