wickes-css2 2.110.0 → 2.111.0-complete-your-project.1

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.
Files changed (112) hide show
  1. package/build/css/category-main.css +1 -1
  2. package/build/css/homepage-main.css +1 -1
  3. package/build/css/kitchen-plp-main.css +1 -1
  4. package/build/css/main.css +1 -1
  5. package/build/css/my-account-main-v2.css +1 -1
  6. package/build/css/my-account-main.css +1 -1
  7. package/build/css/pages/page_personal-details.css +1 -1
  8. package/build/css/pages/page_product-details-v2.css +1 -1
  9. package/build/css/pdp-main-before-combine.css +1 -1
  10. package/build/css/pdp-main-critical.css +1 -1
  11. package/build/css/pdp-main-non-critical.css +1 -1
  12. package/build/css/pdp-main.css +1 -1
  13. package/build/css/plp-main.css +1 -1
  14. package/build/css/store-locator-main.css +1 -1
  15. package/build/js/account-hub.min.js +1 -1
  16. package/build/js/basket.min.js +1 -1
  17. package/build/js/bloomreach-widget.min.js +1 -0
  18. package/build/js/bundle.min.js +1 -1
  19. package/build/js/checkout.min.js +1 -1
  20. package/build/js/emulation.min.js +3025 -217
  21. package/build/js/general.bundle.min.js +1 -1
  22. package/build/js/merged-checkout.min.js +1 -1
  23. package/build/js/page/bloomreach-widget.js +1148 -0
  24. package/build/js/page/utils/create-count-stepper.js +30 -9
  25. package/build/js/page/utils/create-loading-button.js +37 -0
  26. package/build/js/page/utils/create-toast.js +79 -0
  27. package/build/js/page/utils/custom-dropdown.js +80 -0
  28. package/build/js/pdp-count-stepper.min.js +1 -1
  29. package/build/js/pdp.bundle.min.js +1 -1
  30. package/build/js/plp.bundle.min.js +1 -1
  31. package/build/js/project-list.min.js +1 -1
  32. package/build/js/saving-shopping-list.min.js +1 -1
  33. package/package.json +1 -1
  34. package/src/components/base/button.hbs +23 -5
  35. package/src/components/bloomreach/complete-card-dropdown.hbs +47 -0
  36. package/src/components/bloomreach/complete-card-skeleton.hbs +19 -0
  37. package/src/components/bloomreach/complete-card.hbs +138 -0
  38. package/src/components/bloomreach/complete-divider.hbs +3 -0
  39. package/src/components/bloomreach/complete-summary-skeleton.hbs +12 -0
  40. package/src/components/bloomreach/complete-summary.hbs +43 -0
  41. package/src/components/bloomreach/complete-wrapper.hbs +1 -0
  42. package/src/components/bloomreach/complete-your-project.hbs +21 -0
  43. package/src/components/gift-cards.hbs +1 -1
  44. package/src/elements/checkbox.hbs +8 -1
  45. package/src/js/components/general/cart-slider.js +19 -6
  46. package/src/js/emulation/bloomreach-widget-calculations.js +140 -0
  47. package/src/js/emulation/bloomreach-widget-loading.js +11 -0
  48. package/src/js/emulation/mock.js +3097 -1
  49. package/src/js/emulation/notify-me.js +1 -1
  50. package/src/js/page/bloomreach-widget.js +1148 -0
  51. package/src/js/page/utils/create-count-stepper.js +30 -9
  52. package/src/js/page/utils/create-loading-button.js +37 -0
  53. package/src/js/page/utils/create-toast.js +79 -0
  54. package/src/js/page/utils/custom-dropdown.js +80 -0
  55. package/src/page_product-details-banner.html +0 -1
  56. package/src/page_product-details-big-wins-disabled-delivery.html +0 -1
  57. package/src/page_product-details-big-wins-non-registered.html +0 -1
  58. package/src/page_product-details-big-wins-out-nearest.html +0 -1
  59. package/src/page_product-details-big-wins-unhappy.html +0 -1
  60. package/src/page_product-details-big-wins.html +0 -1
  61. package/src/page_product-details-billie.html +0 -1
  62. package/src/page_product-details-bloomreach.html +130 -0
  63. package/src/page_product-details-calculator.html +0 -1
  64. package/src/page_product-details-cashback-v2.html +0 -1
  65. package/src/page_product-details-clearpay.html +0 -1
  66. package/src/page_product-details-cnc-error-notification.html +0 -1
  67. package/src/page_product-details-cnc-success-notification-vat.html +0 -1
  68. package/src/page_product-details-cnc-success-notification.html +0 -1
  69. package/src/page_product-details-default-store.html +0 -1
  70. package/src/page_product-details-energy-efficiency.html +0 -1
  71. package/src/page_product-details-flooring-with-pr-placeholder.html +0 -1
  72. package/src/page_product-details-flooring.html +0 -1
  73. package/src/page_product-details-gallery-actual.html +0 -1
  74. package/src/page_product-details-mfe-calculator.html +0 -1
  75. package/src/page_product-details-minimum-v2.html +0 -1
  76. package/src/page_product-details-mtm-doors.html +0 -1
  77. package/src/page_product-details-only-clearpay.html +0 -1
  78. package/src/page_product-details-paint-mixing.html +0 -1
  79. package/src/page_product-details-saved-pl.html +0 -1
  80. package/src/page_product-details-tile-steps-klarna-widget-with-method-ids.html +0 -1
  81. package/src/page_product-details-tile-steps-logout.html +0 -1
  82. package/src/page_product-details-tile-steps-no-new-project-list.html +0 -1
  83. package/src/page_product-details-tile-steps-with-klarna.html +0 -1
  84. package/src/page_product-details-tile-steps.html +0 -1
  85. package/src/page_product-details-v2.html +0 -1
  86. package/src/page_product-details-vat.html +0 -1
  87. package/src/page_product-details-wisdom-mcfc-registered.html +0 -1
  88. package/src/page_product-details-wisdom-mcfc.html +0 -1
  89. package/src/page_product-details-wisdom-oos-registered.html +0 -1
  90. package/src/page_product-details-wisdom-oos.html +0 -1
  91. package/src/page_product-details-wisdom-registered.html +0 -1
  92. package/src/page_product-details-wisdom.html +0 -1
  93. package/src/page_product-details-with-favourite.html +0 -1
  94. package/src/page_product-details-with-global-search-v2.html +7 -1
  95. package/src/page_product-details_no-previous-default.html +0 -1
  96. package/src/page_track-my-order-result.html +1 -0
  97. package/src/partials/scripts.hbs +1 -0
  98. package/src/scss/common/_common.scss +1 -0
  99. package/src/scss/common/_elements.scss +13 -1
  100. package/src/scss/common/_loading-button.scss +49 -0
  101. package/src/scss/components/_notifications.scss +86 -5
  102. package/src/scss/components/bloomreach/_bloomreach.scss +3 -0
  103. package/src/scss/components/bloomreach/_complete-card-dropdown.scss +174 -0
  104. package/src/scss/components/bloomreach/_complete-card.scss +402 -0
  105. package/src/scss/components/bloomreach/_complete-your-project.scss +207 -0
  106. package/src/scss/helpers/_variables.scss +1 -0
  107. package/src/scss/pages/page_product-details-v2.scss +45 -2
  108. package/src/scss/pdp-main-critical.scss +0 -1
  109. package/src/scss/pdp-main.scss +1 -1
  110. package/src/sitemap.html +6 -0
  111. package/src/scss/components/_pdp-action-v2-critical.scss +0 -27
  112. package/src/scss/components/_pdp-action-v2.scss +0 -27
@@ -0,0 +1,1148 @@
1
+ var Wick = window.Wick || {};
2
+
3
+ import { createCountStepper } from './utils/create-count-stepper';
4
+ import { createEvent } from './utils/create-event';
5
+ import { createDropdown } from './utils/custom-dropdown';
6
+ import { createLoadingButton } from './utils/create-loading-button';
7
+ import { createToast } from './utils/create-toast';
8
+
9
+ const Handlebars = require('hbsfy/runtime');
10
+
11
+ Handlebars.registerPartial('checkbox', require('../../elements/checkbox.hbs'));
12
+ Handlebars.registerPartial('loader', require('../../elements/loader.hbs'));
13
+ Handlebars.registerPartial('button', require('../../components/base/button.hbs'));
14
+ Handlebars.registerPartial(
15
+ 'bloomreach/complete-card-dropdown',
16
+ require('../../components/bloomreach/complete-card-dropdown.hbs')
17
+ );
18
+ Handlebars.registerPartial('notifications', require('../../elements/notifications.hbs'));
19
+
20
+ const notificationTemplate = require('../../elements/notifications.hbs');
21
+ const completeWrapperTemplate = require('../../components/bloomreach/complete-wrapper.hbs');
22
+ const completeDividerTemplate = require('../../components/bloomreach/complete-divider.hbs');
23
+ const completeCardTemplate = require('../../components/bloomreach/complete-card.hbs');
24
+ const completeSummaryTemplate = require('../../components/bloomreach/complete-summary.hbs');
25
+
26
+ Wick.BloomreachWidget = {
27
+ CALCULATE_PRODUCT_BUNDLE_TOTAL_EVENT: 'calculateProductBundleTotal',
28
+ ADD_PRODUCT_BUNDLE_TO_CART_EVENT: 'bulkAddToCart',
29
+
30
+ steppers: [],
31
+ recommendations: [],
32
+ dropdown: null,
33
+ loadingButton: null,
34
+ lastCalculationResponse: null,
35
+ dropdownCurrent: {},
36
+ toast: null,
37
+
38
+ el: {
39
+ cardCheckbox: '.complete-card__select input[type="checkbox"]',
40
+ completeCard: '.complete-card',
41
+ completeWidget: '.complete-widget',
42
+ countBtn: '.count-btn',
43
+ countStepperInitializedData: 'count-stepper-initialized',
44
+ countStepperRoot: '.count-stepper',
45
+ ctaButton: '.complete-widget__cta .btn',
46
+ ctaButtonText: '.loading-button__text',
47
+ ctaButtonLoader: '.loading-button__loader',
48
+ summaryPriceValue: '.complete-widget__price-value',
49
+ summarySalePrice: '.complete-widget__sale-price',
50
+
51
+ dropdownErrorClass: 'complete-card-dropdown--error',
52
+ dropdownOpenClass: 'complete-card-dropdown--open',
53
+ dropdownOption: '[data-complete-card-dropdown-option]',
54
+ dropdownOptionSelectedClass: 'complete-card-dropdown__option--selected',
55
+ dropdownRoot: '[data-complete-card-dropdown]',
56
+ dropdownToggle: '[data-complete-card-dropdown-toggle]',
57
+ dropdownValue: '[data-complete-card-dropdown-value]',
58
+
59
+ optionsEl: '.complete-card__options',
60
+ previousQuantityData: 'previous-quantity',
61
+ quantityInput: '.tbx_quantity',
62
+ quantityReadyData: 'quantity-ready',
63
+
64
+ recommendationIndexAttr: 'data-recommendation-index',
65
+ selectedClass: 'complete-card--selected',
66
+ selectedValueData: 'selected-value',
67
+ starOverlay: '.star-overlay',
68
+
69
+ titleEl: '.complete-card__title',
70
+
71
+ widgetContainer: '[data-complete-widget]',
72
+ widgetContent: '[data-complete-widget-content]',
73
+ widgetWrapper: '[data-complete-widget-wrapper]',
74
+ },
75
+
76
+ badgeColorMap: {
77
+ blue: '#019ee3',
78
+ gray: '#3e3e3e',
79
+ green: '#9acd32',
80
+ red: '#cf000f',
81
+ yellow: '#f7ca18',
82
+ },
83
+
84
+ getCtaText(selectedCount) {
85
+ if (!selectedCount) {
86
+ return 'Add product(s) to basket';
87
+ }
88
+
89
+ return `Add ${selectedCount} product${selectedCount > 1 ? 's' : ''} to basket`;
90
+ },
91
+
92
+ setCtaText($button, text) {
93
+ const { ctaButtonText } = Wick.BloomreachWidget.el;
94
+ const $text = $button.find(ctaButtonText);
95
+
96
+ if ($text.length) {
97
+ $text.text(text);
98
+ return;
99
+ }
100
+
101
+ $button.text(text);
102
+ },
103
+
104
+ getBadgeColor(color) {
105
+ return Wick.BloomreachWidget.badgeColorMap[color] || color;
106
+ },
107
+
108
+ hasRecommendations(payloadData) {
109
+ if (Array.isArray(payloadData)) {
110
+ return payloadData.length > 0;
111
+ }
112
+
113
+ return Boolean(
114
+ payloadData &&
115
+ Array.isArray(payloadData.recommendedProducts) &&
116
+ payloadData.recommendedProducts.length
117
+ );
118
+ },
119
+
120
+ normalizePayload(payloadData) {
121
+ if (Array.isArray(payloadData)) {
122
+ return payloadData;
123
+ }
124
+
125
+ if (payloadData && Array.isArray(payloadData.recommendedProducts)) {
126
+ return payloadData.recommendedProducts;
127
+ }
128
+
129
+ return [];
130
+ },
131
+
132
+ getDisplayPrice(product) {
133
+ return product.price || product.displayPrice || {};
134
+ },
135
+
136
+ dispatchWidgetEvent(eventName, payload) {
137
+ return new Promise(function (resolve, reject) {
138
+ const eventDetail = { resolve, reject };
139
+ const event = createEvent(eventName, payload, eventDetail);
140
+
141
+ window.dispatchEvent(event);
142
+ });
143
+ },
144
+
145
+ getProductImage(product, fallbackProduct) {
146
+ const productImages = product.images || [];
147
+ const fallbackImages = fallbackProduct ? fallbackProduct.images || [] : [];
148
+ const images = productImages.length ? productImages : fallbackImages;
149
+
150
+ return (
151
+ images.find(function (item) {
152
+ return item.format === 'product';
153
+ }) ||
154
+ images.find(function (item) {
155
+ return item.imageType === 'PRIMARY';
156
+ }) ||
157
+ images[0] ||
158
+ {}
159
+ );
160
+ },
161
+
162
+ getDropdownOptions(product) {
163
+ if (!product.variantOptions || !product.variantOptions.length) {
164
+ return [];
165
+ }
166
+
167
+ return product.variantOptions.map(function (variantOption) {
168
+ const qualifiers = variantOption.variantOptionQualifiers || [];
169
+
170
+ const label = qualifiers
171
+ .map(function (qualifier) {
172
+ return qualifier.value;
173
+ })
174
+ .join(', ');
175
+
176
+ return {
177
+ label,
178
+ value: variantOption.code,
179
+ };
180
+ });
181
+ },
182
+
183
+ getSelectedDropdownLabel(options, selectedValue) {
184
+ const selectedOption = options.find(function (option) {
185
+ return option.value === selectedValue;
186
+ });
187
+
188
+ return selectedOption ? selectedOption.label : '';
189
+ },
190
+
191
+ handleBulkAddToCartResponse(response) {
192
+ const bulkData = response && response.bulkAddToCartData;
193
+
194
+ if (!bulkData) {
195
+ return;
196
+ }
197
+
198
+ Wick.BloomreachWidget.toast.show({
199
+ type: bulkData.messageType,
200
+ text: bulkData.messageText,
201
+ });
202
+ },
203
+
204
+ getBadge(product) {
205
+ const promotion = product.potentialPromotions && product.potentialPromotions[0];
206
+ const promotionAttributes = promotion && promotion.customAttributes;
207
+
208
+ if (promotionAttributes && promotionAttributes.overlayText) {
209
+ return {
210
+ text: promotionAttributes.overlayText,
211
+ textColor: Wick.BloomreachWidget.getBadgeColor(
212
+ promotionAttributes.overlayTextColor
213
+ ),
214
+ color: Wick.BloomreachWidget.getBadgeColor(
215
+ promotionAttributes.overlayBackgroundColor
216
+ ),
217
+ };
218
+ }
219
+
220
+ return product.badge;
221
+ },
222
+
223
+ getWasPriceFormatted(product) {
224
+ const price = Wick.BloomreachWidget.getDisplayPrice(product);
225
+ const wasPrice = price && price.wasPrice;
226
+
227
+ if (wasPrice && wasPrice.formattedValue) {
228
+ return wasPrice.formattedValue;
229
+ }
230
+
231
+ if (wasPrice) {
232
+ return `${price.currencySymbol || '£'}${wasPrice}`;
233
+ }
234
+
235
+ return '';
236
+ },
237
+
238
+ getDisplayPriceExcVat(product) {
239
+ return product.displayPriceExclusiveVat || product.priceExclusiveVat || null;
240
+ },
241
+
242
+ getExcVatWasPrice(product) {
243
+ const display = product.displayPriceExclusiveVat;
244
+ const raw = product.priceExclusiveVat;
245
+ if (display && typeof display.wasPrice === 'number') return display.wasPrice;
246
+ if (raw && typeof raw.wasPrice === 'number') return raw.wasPrice;
247
+ return null;
248
+ },
249
+
250
+ getExcVatFormattedValue(displayPrice, product) {
251
+ const excVat = product ? Wick.BloomreachWidget.getDisplayPriceExcVat(product) : null;
252
+ if (excVat && excVat.formattedValue) {
253
+ return excVat.formattedValue;
254
+ }
255
+ if (!displayPrice || typeof displayPrice.value !== 'number') {
256
+ return displayPrice ? displayPrice.formattedValue || '' : '';
257
+ }
258
+ const vatRate = displayPrice.vatRatePercentage || 20;
259
+ return Wick.BloomreachWidget.formatPrice(displayPrice.value / (1 + vatRate / 100));
260
+ },
261
+
262
+ getProductRenderData(product, index, options = {}) {
263
+ const shouldShowDropdown = index !== 0;
264
+ const dropdownOptions = shouldShowDropdown
265
+ ? Wick.BloomreachWidget.getDropdownOptions(product)
266
+ : [];
267
+ const selectedDropdownValue = options.selectedDropdownValue || '';
268
+ const selectedDropdownLabel = Wick.BloomreachWidget.getSelectedDropdownLabel(
269
+ dropdownOptions,
270
+ selectedDropdownValue
271
+ );
272
+ const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
273
+ const showFromPrice = Boolean(
274
+ index !== 0 &&
275
+ !selectedDropdownValue &&
276
+ displayPrice &&
277
+ displayPrice.priceType === 'FROM'
278
+ );
279
+
280
+ const wasPriceFormatted = Wick.BloomreachWidget.getWasPriceFormatted(product);
281
+ const excVatFormattedValue = Wick.BloomreachWidget.getExcVatFormattedValue(
282
+ displayPrice,
283
+ product
284
+ );
285
+ const isSwitchVat = !!(window.ACC && window.ACC.app && window.ACC.app.isVatToggleAvailable);
286
+
287
+ let excVatWasPriceFormatted = '';
288
+ if (wasPriceFormatted) {
289
+ const excVatWasPrice = Wick.BloomreachWidget.getExcVatWasPrice(product);
290
+ if (excVatWasPrice !== null) {
291
+ excVatWasPriceFormatted = Wick.BloomreachWidget.formatPrice(excVatWasPrice);
292
+ } else if (typeof displayPrice.wasPrice === 'number') {
293
+ const vatRate = displayPrice.vatRatePercentage || 20;
294
+ excVatWasPriceFormatted = Wick.BloomreachWidget.formatPrice(
295
+ displayPrice.wasPrice / (1 + vatRate / 100)
296
+ );
297
+ }
298
+ }
299
+
300
+ return {
301
+ ...product,
302
+ badge: Wick.BloomreachWidget.getBadge(product),
303
+ price: displayPrice,
304
+ wasPriceFormatted,
305
+ 'switch-vat': isSwitchVat,
306
+ incVatFormattedValue: displayPrice.formattedValue || '',
307
+ excVatFormattedValue,
308
+ incVatWasPriceFormatted: wasPriceFormatted,
309
+ excVatWasPriceFormatted,
310
+ showFromPrice,
311
+ image:
312
+ options.image ||
313
+ Wick.BloomreachWidget.getProductImage(product, options.fallbackProduct),
314
+ dropdownOptions: dropdownOptions.map(function (option) {
315
+ return {
316
+ ...option,
317
+ selected: option.value === selectedDropdownValue,
318
+ };
319
+ }),
320
+ checkboxId: `${product.code}-${index}`,
321
+ dropdownError: options.dropdownError || false,
322
+ checked: options.checked || false,
323
+ selectedDropdownValue,
324
+ selectedDropdownLabel,
325
+ };
326
+ },
327
+
328
+ renderWidget($container, context) {
329
+ const { widgetContent, widgetWrapper, completeCard, recommendationIndexAttr } =
330
+ Wick.BloomreachWidget.el;
331
+
332
+ const $content = $container.find(widgetContent);
333
+ const recommendations = Wick.BloomreachWidget.normalizePayload(context);
334
+
335
+ if (!$content.length || !recommendations.length) {
336
+ return;
337
+ }
338
+
339
+ Wick.BloomreachWidget.recommendations = recommendations;
340
+
341
+ $content.html(completeWrapperTemplate());
342
+
343
+ const $wrapper = $content.find(widgetWrapper);
344
+
345
+ Wick.BloomreachWidget.dropdownCurrent = {};
346
+
347
+ recommendations.forEach(function (recommendation, index) {
348
+ const product = Wick.BloomreachWidget.getProductRenderData(
349
+ recommendation.baseProduct,
350
+ index
351
+ );
352
+
353
+ $wrapper.append(completeCardTemplate(product));
354
+
355
+ const $card = $wrapper.children(completeCard).last();
356
+
357
+ $card.attr(recommendationIndexAttr, index);
358
+
359
+ if (index === 0 && recommendations.length > 1) {
360
+ $wrapper.append(completeDividerTemplate());
361
+ }
362
+ });
363
+
364
+ const isSwitchVat = !!(window.ACC && window.ACC.app && window.ACC.app.isVatToggleAvailable);
365
+ $content.append(completeSummaryTemplate({ 'switch-vat': isSwitchVat }));
366
+ },
367
+
368
+ renderWidgetFromPayload(payloadData) {
369
+ const { widgetContainer, completeWidget } = Wick.BloomreachWidget.el;
370
+ const $containers = $(widgetContainer);
371
+
372
+ if (!$containers.length) {
373
+ return;
374
+ }
375
+
376
+ if (!Wick.BloomreachWidget.hasRecommendations(payloadData)) {
377
+ $containers.find(completeWidget).hide();
378
+ return;
379
+ }
380
+
381
+ $containers.each(function () {
382
+ const $container = $(this);
383
+
384
+ Wick.BloomreachWidget.renderWidget($container, payloadData);
385
+ Wick.BloomreachWidget.initRenderedWidget($container);
386
+ });
387
+ },
388
+
389
+ drawRating($root) {
390
+ const $ratingOverlay = $root.find('.rating-overlay');
391
+
392
+ $ratingOverlay.each(function () {
393
+ let rating = parseFloat($(this).attr('data-rating')) || 0;
394
+ const $stars = $(this).children(Wick.BloomreachWidget.el.starOverlay);
395
+
396
+ $stars.each(function () {
397
+ const $star = $(this);
398
+
399
+ if (rating >= 1) {
400
+ rating--;
401
+ } else if (rating > 0) {
402
+ const width = Math.asin(2 * rating - 1) / Math.PI + 0.5;
403
+ $star.css('width', width + 'rem');
404
+ rating = 0;
405
+ } else {
406
+ $star.css('width', '0rem');
407
+ }
408
+ });
409
+ });
410
+ },
411
+
412
+ getDropdownCard($dropdown) {
413
+ return $dropdown.closest(Wick.BloomreachWidget.el.completeCard);
414
+ },
415
+
416
+ getDropdownCheckbox($dropdown) {
417
+ return Wick.BloomreachWidget.getDropdownCard($dropdown).find(
418
+ Wick.BloomreachWidget.el.cardCheckbox
419
+ );
420
+ },
421
+
422
+ setDropdownCheckboxState($dropdown, isChecked, shouldTriggerChange = true) {
423
+ const $checkbox = Wick.BloomreachWidget.getDropdownCheckbox($dropdown);
424
+
425
+ if (!$checkbox.length) {
426
+ return;
427
+ }
428
+
429
+ $checkbox.prop('checked', isChecked);
430
+
431
+ if (shouldTriggerChange) {
432
+ $checkbox.trigger('change');
433
+ }
434
+ },
435
+
436
+ setDropdownError($dropdown, hasError) {
437
+ $dropdown.toggleClass(Wick.BloomreachWidget.el.dropdownErrorClass, hasError);
438
+ },
439
+
440
+ validateDropdown($dropdown, options = {}) {
441
+ const isValid = Boolean($dropdown.data(Wick.BloomreachWidget.el.selectedValueData));
442
+
443
+ Wick.BloomreachWidget.setDropdownError($dropdown, !isValid);
444
+
445
+ if (!isValid && options.uncheck) {
446
+ Wick.BloomreachWidget.setDropdownCheckboxState($dropdown, false, false);
447
+ Wick.BloomreachWidget.getDropdownCard($dropdown).removeClass(
448
+ Wick.BloomreachWidget.el.selectedClass
449
+ );
450
+ }
451
+
452
+ return isValid;
453
+ },
454
+
455
+ validateCardDropdown($card, options = {}) {
456
+ const $dropdown = $card.find(Wick.BloomreachWidget.el.dropdownRoot);
457
+
458
+ if (!$dropdown.length) {
459
+ return true;
460
+ }
461
+
462
+ return Wick.BloomreachWidget.validateDropdown($dropdown, options);
463
+ },
464
+
465
+ findVariantProduct(recommendation, selectedValue) {
466
+ if (!recommendation.variantProducts || !recommendation.variantProducts.length) {
467
+ return null;
468
+ }
469
+
470
+ return recommendation.variantProducts.find(function (variantProduct) {
471
+ return String(variantProduct.code) === String(selectedValue);
472
+ });
473
+ },
474
+
475
+ getCardQuantity($card) {
476
+ const $input = $card.find(Wick.BloomreachWidget.el.quantityInput);
477
+ const quantity = parseInt($input.val(), 10);
478
+
479
+ return Number.isNaN(quantity) ? 1 : quantity;
480
+ },
481
+
482
+ getCardProduct($card) {
483
+ const { recommendationIndexAttr, dropdownRoot, selectedValueData } =
484
+ Wick.BloomreachWidget.el;
485
+
486
+ const recommendationIndex = Number($card.attr(recommendationIndexAttr));
487
+ const recommendation = Wick.BloomreachWidget.recommendations[recommendationIndex];
488
+
489
+ if (!recommendation) {
490
+ return null;
491
+ }
492
+
493
+ const $dropdown = $card.find(dropdownRoot);
494
+ const selectedValue = $dropdown.length ? $dropdown.data(selectedValueData) : '';
495
+
496
+ if (selectedValue) {
497
+ return (
498
+ Wick.BloomreachWidget.findVariantProduct(recommendation, selectedValue) ||
499
+ recommendation.baseProduct
500
+ );
501
+ }
502
+
503
+ return recommendation.baseProduct;
504
+ },
505
+
506
+ getSelectedEntries($root) {
507
+ const { completeCard, cardCheckbox } = Wick.BloomreachWidget.el;
508
+ const entries = [];
509
+
510
+ $root.find(completeCard).each(function () {
511
+ const $card = $(this);
512
+ const $checkbox = $card.find(cardCheckbox);
513
+
514
+ if (!$checkbox.prop('checked')) {
515
+ return;
516
+ }
517
+
518
+ const product = Wick.BloomreachWidget.getCardProduct($card);
519
+
520
+ if (!product) {
521
+ return;
522
+ }
523
+
524
+ entries.push({
525
+ product,
526
+ quantity: Wick.BloomreachWidget.getCardQuantity($card),
527
+ });
528
+ });
529
+
530
+ return entries;
531
+ },
532
+
533
+ getAddToCartEntries($root) {
534
+ return Wick.BloomreachWidget.getSelectedEntries($root).map(function (entry) {
535
+ return {
536
+ productCode: entry.product.code,
537
+ quantity: entry.quantity,
538
+ };
539
+ });
540
+ },
541
+
542
+ updateSummary($root, response = {}) {
543
+ const {
544
+ summaryPriceValue,
545
+ summarySalePrice,
546
+ summaryPriceInc,
547
+ summaryPriceExc,
548
+ summarySalePriceInc,
549
+ summarySalePriceExc,
550
+ } = Wick.BloomreachWidget.el;
551
+
552
+ Wick.BloomreachWidget.lastCalculationResponse = response;
553
+
554
+ const $price = $root.find(summaryPriceValue);
555
+ const $salePrice = $root.find(summarySalePrice);
556
+ const $total = $root.find('.complete-widget__total');
557
+
558
+ if (!$price.length) {
559
+ return;
560
+ }
561
+
562
+ if (response.totalWasPrice) {
563
+ $total.addClass('complete-widget__total-sale');
564
+ const $priceInc = $price.find(summaryPriceInc);
565
+ if ($priceInc.length) {
566
+ $priceInc.text(response.totalWasPrice);
567
+ $price
568
+ .find(summaryPriceExc)
569
+ .text(response.totalExcVatWasPrice || response.totalWasPrice);
570
+ $salePrice.find(summarySalePriceInc).text(response.totalPrice || '');
571
+ $salePrice
572
+ .find(summarySalePriceExc)
573
+ .text(response.totalExcVatPrice || response.totalPrice || '');
574
+ } else {
575
+ $price.text(response.totalWasPrice);
576
+ $salePrice.text(response.totalPrice || '');
577
+ }
578
+ $salePrice.show();
579
+ return;
580
+ }
581
+
582
+ $total.removeClass('complete-widget__total-sale');
583
+ const $priceInc = $price.find(summaryPriceInc);
584
+ if ($priceInc.length) {
585
+ $priceInc.text(response.totalPrice || '£0.00');
586
+ $price
587
+ .find(summaryPriceExc)
588
+ .text(response.totalExcVatPrice || response.totalPrice || '£0.00');
589
+ $salePrice.find(summarySalePriceInc).text('');
590
+ $salePrice.find(summarySalePriceExc).text('');
591
+ $salePrice.hide();
592
+ } else {
593
+ $price.text(response.totalPrice || '£0.00');
594
+ $salePrice.text('').hide();
595
+ }
596
+ },
597
+
598
+ updateCta($root) {
599
+ const { ctaButton, cardCheckbox } = Wick.BloomreachWidget.el;
600
+ const selectedCount = $root.find(cardCheckbox).filter(':checked').length;
601
+ const $cta = $root.find(ctaButton);
602
+
603
+ if (!$cta.length) {
604
+ return;
605
+ }
606
+
607
+ $cta.prop('disabled', !selectedCount);
608
+ Wick.BloomreachWidget.setCtaText($cta, Wick.BloomreachWidget.getCtaText(selectedCount));
609
+ },
610
+
611
+ dispatchCalculateTotal($root) {
612
+ Wick.BloomreachWidget.updateCta($root);
613
+
614
+ return Wick.BloomreachWidget.dispatchWidgetEvent(
615
+ Wick.BloomreachWidget.CALCULATE_PRODUCT_BUNDLE_TOTAL_EVENT,
616
+ {
617
+ entries: Wick.BloomreachWidget.getSelectedEntries($root),
618
+ }
619
+ ).then(function (response) {
620
+ Wick.BloomreachWidget.updateSummary($root, response);
621
+ });
622
+ },
623
+
624
+ dispatchAddToCart($root, $button) {
625
+ Wick.BloomreachWidget.loadingButton.start($button);
626
+
627
+ return new Promise(function (resolve, reject) {
628
+ let timeoutId;
629
+
630
+ const cleanup = function () {
631
+ window.removeEventListener('productAddedToCart', onProductAddedToCart);
632
+ window.clearTimeout(timeoutId);
633
+ };
634
+
635
+ const onProductAddedToCart = function (event) {
636
+ const response = event.detail || {};
637
+
638
+ if (!response.bulkAddToCartData) {
639
+ return;
640
+ }
641
+
642
+ cleanup();
643
+ resolve(response);
644
+ };
645
+
646
+ window.addEventListener('productAddedToCart', onProductAddedToCart);
647
+
648
+ timeoutId = window.setTimeout(function () {
649
+ cleanup();
650
+ reject();
651
+ }, 10000);
652
+
653
+ window.dispatchEvent(
654
+ new CustomEvent(Wick.BloomreachWidget.ADD_PRODUCT_BUNDLE_TO_CART_EVENT, {
655
+ detail: {
656
+ entries: Wick.BloomreachWidget.getAddToCartEntries($root),
657
+ reject: function (error) {
658
+ cleanup();
659
+ reject(error);
660
+ },
661
+ },
662
+ })
663
+ );
664
+ })
665
+ .then(function (response) {
666
+ Wick.BloomreachWidget.handleBulkAddToCartResponse(response);
667
+ })
668
+ .catch(function () {
669
+ Wick.BloomreachWidget.handleBulkAddToCartResponse({
670
+ bulkAddToCartData: {
671
+ messageType: 'error',
672
+ messageText: 'Selected product(s) were not added to basket',
673
+ },
674
+ });
675
+ })
676
+ .finally(function () {
677
+ Wick.BloomreachWidget.loadingButton.stop($button);
678
+ Wick.BloomreachWidget.updateCta($root);
679
+ });
680
+ },
681
+
682
+ reinitCard($card) {
683
+ const { countBtn, completeWidget } = Wick.BloomreachWidget.el;
684
+
685
+ $card.find(countBtn).remove();
686
+
687
+ Wick.BloomreachWidget.initQuantityFields($card);
688
+ Wick.BloomreachWidget.drawRating($card);
689
+ Wick.BloomreachWidget.alignCardBlocks($card.closest(completeWidget));
690
+ },
691
+
692
+ replaceCardWithBaseProduct($dropdown, options = {}) {
693
+ const {
694
+ completeCard,
695
+ recommendationIndexAttr,
696
+ dropdownRoot,
697
+ dropdownErrorClass,
698
+ cardCheckbox,
699
+ } = Wick.BloomreachWidget.el;
700
+
701
+ const $card = $dropdown.closest(completeCard);
702
+ const recommendationIndex = Number($card.attr(recommendationIndexAttr));
703
+ const recommendation = Wick.BloomreachWidget.recommendations[recommendationIndex];
704
+
705
+ if (!recommendation || !recommendation.baseProduct) {
706
+ return null;
707
+ }
708
+
709
+ const productData = Wick.BloomreachWidget.getProductRenderData(
710
+ recommendation.baseProduct,
711
+ recommendationIndex,
712
+ {
713
+ dropdownError: options.dropdownError || false,
714
+ checked: false,
715
+ }
716
+ );
717
+
718
+ const newCardHtml = completeCardTemplate(productData);
719
+ const $newCard = $(newCardHtml);
720
+
721
+ $newCard.attr(recommendationIndexAttr, recommendationIndex);
722
+
723
+ if (options.dropdownError) {
724
+ $newCard.find(dropdownRoot).addClass(dropdownErrorClass);
725
+ }
726
+
727
+ $card.replaceWith($newCard);
728
+
729
+ $newCard.find(cardCheckbox).prop('checked', false);
730
+
731
+ $newCard
732
+ .find(Wick.BloomreachWidget.el.quantityInput)
733
+ .val(1)
734
+ .data(Wick.BloomreachWidget.el.previousQuantityData, 1)
735
+ .removeData(Wick.BloomreachWidget.el.quantityReadyData)
736
+ .removeData(Wick.BloomreachWidget.el.countStepperInitializedData);
737
+
738
+ Wick.BloomreachWidget.reinitCard($newCard);
739
+
740
+ return $newCard;
741
+ },
742
+
743
+ replaceCardWithVariant($dropdown, selectedValue) {
744
+ const {
745
+ completeCard,
746
+ recommendationIndexAttr,
747
+ selectedClass,
748
+ dropdownRoot,
749
+ selectedValueData,
750
+ cardCheckbox,
751
+ } = Wick.BloomreachWidget.el;
752
+
753
+ const $card = $dropdown.closest(completeCard);
754
+ const recommendationIndex = Number($card.attr(recommendationIndexAttr));
755
+ const recommendation = Wick.BloomreachWidget.recommendations[recommendationIndex];
756
+
757
+ if (!recommendation) {
758
+ return null;
759
+ }
760
+
761
+ const variantProduct = Wick.BloomreachWidget.findVariantProduct(
762
+ recommendation,
763
+ selectedValue
764
+ );
765
+
766
+ if (!variantProduct) {
767
+ return null;
768
+ }
769
+
770
+ const productData = Wick.BloomreachWidget.getProductRenderData(
771
+ {
772
+ ...variantProduct,
773
+ variantOptions: recommendation.baseProduct.variantOptions,
774
+ },
775
+ recommendationIndex,
776
+ {
777
+ fallbackProduct: recommendation.baseProduct,
778
+ checked: true,
779
+ selectedDropdownValue: selectedValue,
780
+ }
781
+ );
782
+
783
+ const newCardHtml = completeCardTemplate(productData);
784
+ const $newCard = $(newCardHtml);
785
+
786
+ $newCard.attr(recommendationIndexAttr, recommendationIndex);
787
+ $newCard.addClass(selectedClass);
788
+
789
+ const $newDropdown = $newCard.find(dropdownRoot);
790
+
791
+ if ($newDropdown.length) {
792
+ $newDropdown.data(selectedValueData, selectedValue);
793
+ }
794
+
795
+ $card.replaceWith($newCard);
796
+
797
+ $newCard.find(cardCheckbox).prop('checked', true);
798
+
799
+ $newCard
800
+ .find(Wick.BloomreachWidget.el.quantityInput)
801
+ .val(1)
802
+ .data(Wick.BloomreachWidget.el.previousQuantityData, 1)
803
+ .removeData(Wick.BloomreachWidget.el.quantityReadyData)
804
+ .removeData(Wick.BloomreachWidget.el.countStepperInitializedData);
805
+
806
+ Wick.BloomreachWidget.reinitCard($newCard);
807
+
808
+ return $newCard;
809
+ },
810
+
811
+ handleDropdownSelect($dropdown, selectedValue) {
812
+ const $card = $dropdown.closest(Wick.BloomreachWidget.el.completeCard);
813
+ const recommendationIndex = $card.attr(Wick.BloomreachWidget.el.recommendationIndexAttr);
814
+ const currentValue = Wick.BloomreachWidget.dropdownCurrent[recommendationIndex];
815
+
816
+ if (`${currentValue}` === `${selectedValue}`) {
817
+ return;
818
+ }
819
+
820
+ Wick.BloomreachWidget.dropdownCurrent[recommendationIndex] = selectedValue;
821
+
822
+ const $completeWidget = $dropdown.closest(Wick.BloomreachWidget.el.completeWidget);
823
+ const isPlaceholder = !selectedValue;
824
+
825
+ if (isPlaceholder) {
826
+ Wick.BloomreachWidget.setDropdownError($dropdown, true);
827
+ Wick.BloomreachWidget.setDropdownCheckboxState($dropdown, false, false);
828
+ Wick.BloomreachWidget.replaceCardWithBaseProduct($dropdown, {
829
+ dropdownError: true,
830
+ });
831
+
832
+ if ($completeWidget.length) {
833
+ Wick.BloomreachWidget.dispatchCalculateTotal($completeWidget);
834
+ }
835
+
836
+ return;
837
+ }
838
+
839
+ Wick.BloomreachWidget.setDropdownError($dropdown, false);
840
+ Wick.BloomreachWidget.setDropdownCheckboxState($dropdown, true, false);
841
+ Wick.BloomreachWidget.replaceCardWithVariant($dropdown, selectedValue);
842
+
843
+ if ($completeWidget.length) {
844
+ Wick.BloomreachWidget.dispatchCalculateTotal($completeWidget);
845
+ }
846
+ },
847
+
848
+ bindDropdowns() {
849
+ const {
850
+ dropdownRoot,
851
+ dropdownToggle,
852
+ dropdownValue,
853
+ dropdownOption,
854
+ dropdownOpenClass,
855
+ dropdownOptionSelectedClass,
856
+ } = Wick.BloomreachWidget.el;
857
+
858
+ Wick.BloomreachWidget.dropdown = createDropdown({
859
+ root: dropdownRoot,
860
+ toggle: dropdownToggle,
861
+ value: dropdownValue,
862
+ option: dropdownOption,
863
+ openClass: dropdownOpenClass,
864
+ selectedClass: dropdownOptionSelectedClass,
865
+ namespace: 'bloomreachDropdown',
866
+ onSelect($dropdown, $option, selectedValue) {
867
+ Wick.BloomreachWidget.handleDropdownSelect($dropdown, selectedValue);
868
+ },
869
+ });
870
+
871
+ Wick.BloomreachWidget.dropdown.bind();
872
+ },
873
+
874
+ bindCardSelection($root) {
875
+ const { completeCard, cardCheckbox, selectedClass } = Wick.BloomreachWidget.el;
876
+
877
+ const $firstCard = $root.find(completeCard).first();
878
+
879
+ $firstCard.find(cardCheckbox).prop('checked', true);
880
+ $firstCard.addClass(selectedClass);
881
+
882
+ $root.off('change.bloomreachCardSelection', cardCheckbox);
883
+ $root.on('change.bloomreachCardSelection', cardCheckbox, function () {
884
+ const $checkbox = $(this);
885
+ const $card = $checkbox.closest(completeCard);
886
+ const $dropdown = $card.find(Wick.BloomreachWidget.el.dropdownRoot);
887
+
888
+ if (
889
+ !$checkbox.prop('checked') &&
890
+ $dropdown.hasClass(Wick.BloomreachWidget.el.dropdownErrorClass)
891
+ ) {
892
+ $card.removeClass(selectedClass);
893
+ return;
894
+ }
895
+
896
+ if (
897
+ $checkbox.prop('checked') &&
898
+ !Wick.BloomreachWidget.validateCardDropdown($card, {
899
+ uncheck: true,
900
+ })
901
+ ) {
902
+ $checkbox.prop('checked', false);
903
+ $card.removeClass(selectedClass);
904
+ return;
905
+ }
906
+
907
+ $card.toggleClass(selectedClass, this.checked);
908
+
909
+ Wick.BloomreachWidget.dispatchCalculateTotal($root);
910
+ });
911
+ },
912
+
913
+ bindDropdownValidation($root) {
914
+ const { cardCheckbox, completeCard } = Wick.BloomreachWidget.el;
915
+
916
+ $root.off('click.bloomreachDropdownValidation', cardCheckbox);
917
+ $root.on('click.bloomreachDropdownValidation', cardCheckbox, function () {
918
+ const $checkbox = $(this);
919
+ const $card = $checkbox.closest(completeCard);
920
+
921
+ if (
922
+ $checkbox.prop('checked') &&
923
+ !Wick.BloomreachWidget.validateCardDropdown($card, {
924
+ uncheck: true,
925
+ })
926
+ ) {
927
+ $checkbox.prop('checked', false);
928
+ $card.removeClass(Wick.BloomreachWidget.el.selectedClass);
929
+ }
930
+ });
931
+ },
932
+
933
+ bindAddToCart($root) {
934
+ const { ctaButton } = Wick.BloomreachWidget.el;
935
+
936
+ $root.off('click.bloomreachAddToCart', ctaButton);
937
+ $root.on('click.bloomreachAddToCart', ctaButton, function (event) {
938
+ event.preventDefault();
939
+
940
+ const $button = $(this);
941
+
942
+ if (
943
+ $button.prop('disabled') ||
944
+ Wick.BloomreachWidget.loadingButton.isLoading($button)
945
+ ) {
946
+ return;
947
+ }
948
+
949
+ Wick.BloomreachWidget.dispatchAddToCart($root, $button);
950
+ });
951
+ },
952
+
953
+ alignBlock(selector, $root) {
954
+ const $els = $root.find(selector);
955
+
956
+ $els.css('min-height', '');
957
+
958
+ if (!$els.length || Wick.Responsive.getCurrentBreakpoint() !== 'up-lg') {
959
+ return;
960
+ }
961
+
962
+ let maxHeight = 0;
963
+
964
+ $els.each(function () {
965
+ maxHeight = Math.max(maxHeight, $(this).height());
966
+ });
967
+
968
+ if (maxHeight > 0) {
969
+ $els.css('min-height', maxHeight + 'px');
970
+ }
971
+ },
972
+
973
+ alignCardBlocks($root) {
974
+ const { titleEl, optionsEl } = Wick.BloomreachWidget.el;
975
+
976
+ Wick.BloomreachWidget.alignBlock(titleEl, $root);
977
+ Wick.BloomreachWidget.alignBlock(optionsEl, $root);
978
+ },
979
+
980
+ setInitialSummary($root) {
981
+ const entries = Wick.BloomreachWidget.getSelectedEntries($root);
982
+ const firstEntry = entries[0];
983
+
984
+ if (!firstEntry || !firstEntry.product) {
985
+ return;
986
+ }
987
+
988
+ const product = firstEntry.product;
989
+ const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
990
+ const priceExcVat = Wick.BloomreachWidget.getDisplayPriceExcVat(product);
991
+ const wasPriceFormatted = Wick.BloomreachWidget.getWasPriceFormatted(product);
992
+
993
+ const excVatWasPriceRaw = Wick.BloomreachWidget.getExcVatWasPrice(product);
994
+ const excVatWasPrice =
995
+ excVatWasPriceRaw !== null
996
+ ? Wick.BloomreachWidget.formatPrice(excVatWasPriceRaw)
997
+ : null;
998
+
999
+ Wick.BloomreachWidget.updateSummary($root, {
1000
+ totalPrice: displayPrice.formattedValue || '£0.00',
1001
+ totalWasPrice: wasPriceFormatted || null,
1002
+ totalExcVatPrice: priceExcVat ? priceExcVat.formattedValue || '' : '',
1003
+ totalExcVatWasPrice: excVatWasPrice,
1004
+ });
1005
+ },
1006
+
1007
+ initQuantityField($root, inputSel) {
1008
+ const stepper = createCountStepper({
1009
+ inputSel,
1010
+ min: 1,
1011
+ onChange(qty, inputEl) {
1012
+ const $input = $(inputEl);
1013
+ const $card = $input.closest(Wick.BloomreachWidget.el.completeCard);
1014
+ const $completeWidget = $input.closest(Wick.BloomreachWidget.el.completeWidget);
1015
+ const $checkbox = $card.find(Wick.BloomreachWidget.el.cardCheckbox);
1016
+ const previousQuantity =
1017
+ $input.data(Wick.BloomreachWidget.el.previousQuantityData) || 1;
1018
+
1019
+ if (!$input.data(Wick.BloomreachWidget.el.quantityReadyData)) {
1020
+ $input.data(Wick.BloomreachWidget.el.previousQuantityData, qty || 1);
1021
+ return;
1022
+ }
1023
+
1024
+ if (!Wick.BloomreachWidget.validateCardDropdown($card)) {
1025
+ $input.val(previousQuantity);
1026
+
1027
+ const $minus = $card.find('.count-btn--minus');
1028
+
1029
+ if (previousQuantity <= 1) {
1030
+ $minus.prop('disabled', true);
1031
+ }
1032
+
1033
+ return;
1034
+ }
1035
+
1036
+ $checkbox.prop('checked', true);
1037
+ $card.addClass(Wick.BloomreachWidget.el.selectedClass);
1038
+
1039
+ $input.data(Wick.BloomreachWidget.el.previousQuantityData, qty);
1040
+ $input.trigger('change');
1041
+
1042
+ if ($completeWidget.length) {
1043
+ Wick.BloomreachWidget.dispatchCalculateTotal($completeWidget);
1044
+ }
1045
+ },
1046
+ });
1047
+
1048
+ stepper.init($root);
1049
+
1050
+ $root.find(inputSel).data(Wick.BloomreachWidget.el.quantityReadyData, true);
1051
+
1052
+ Wick.BloomreachWidget.steppers.push(stepper);
1053
+ },
1054
+
1055
+ initQuantityFields($root) {
1056
+ const {
1057
+ quantityInput,
1058
+ countStepperInitializedData,
1059
+ countStepperRoot,
1060
+ previousQuantityData,
1061
+ } = Wick.BloomreachWidget.el;
1062
+
1063
+ $root.find(quantityInput).each(function () {
1064
+ const $input = $(this);
1065
+
1066
+ if ($input.data(countStepperInitializedData)) {
1067
+ return;
1068
+ }
1069
+
1070
+ const inputId = $input.attr('id');
1071
+
1072
+ if (!inputId) {
1073
+ return;
1074
+ }
1075
+
1076
+ $input.data(countStepperInitializedData, true);
1077
+ $input.data(previousQuantityData, parseInt($input.val(), 10) || 1);
1078
+
1079
+ Wick.BloomreachWidget.initQuantityField(
1080
+ $input.closest(countStepperRoot),
1081
+ `#${inputId}`
1082
+ );
1083
+ });
1084
+ },
1085
+
1086
+ formatPrice(value) {
1087
+ return new Intl.NumberFormat('en-GB', {
1088
+ style: 'currency',
1089
+ currency: 'GBP',
1090
+ minimumFractionDigits: 2,
1091
+ maximumFractionDigits: 2,
1092
+ }).format(value);
1093
+ },
1094
+
1095
+ initRenderedWidget($container) {
1096
+ if (!Wick.BloomreachWidget.toast) {
1097
+ Wick.BloomreachWidget.toast = createToast({
1098
+ template: notificationTemplate,
1099
+ });
1100
+ }
1101
+ if (!Wick.BloomreachWidget.loadingButton) {
1102
+ Wick.BloomreachWidget.loadingButton = createLoadingButton();
1103
+ }
1104
+ const $completeWidget = $container.find(Wick.BloomreachWidget.el.completeWidget);
1105
+
1106
+ if (!$completeWidget.length) {
1107
+ return;
1108
+ }
1109
+
1110
+ Wick.BloomreachWidget.drawRating($completeWidget);
1111
+ Wick.BloomreachWidget.bindCardSelection($completeWidget);
1112
+ Wick.BloomreachWidget.bindDropdowns();
1113
+ Wick.BloomreachWidget.bindDropdownValidation($completeWidget);
1114
+ Wick.BloomreachWidget.bindAddToCart($completeWidget);
1115
+ Wick.BloomreachWidget.initQuantityFields($completeWidget);
1116
+
1117
+ $completeWidget
1118
+ .find(Wick.BloomreachWidget.el.dropdownRoot)
1119
+ .removeClass(Wick.BloomreachWidget.el.dropdownErrorClass);
1120
+
1121
+ Wick.BloomreachWidget.alignCardBlocks($completeWidget);
1122
+ Wick.BloomreachWidget.updateCta($completeWidget);
1123
+ Wick.BloomreachWidget.setInitialSummary($completeWidget);
1124
+ },
1125
+
1126
+ init(payloadData) {
1127
+ const $containers = $(Wick.BloomreachWidget.el.widgetContainer);
1128
+
1129
+ if (!payloadData || !Wick.BloomreachWidget.hasRecommendations(payloadData)) {
1130
+ $containers.find(Wick.BloomreachWidget.el.completeWidget).hide();
1131
+ return;
1132
+ }
1133
+
1134
+ Wick.BloomreachWidget.renderWidgetFromPayload(payloadData);
1135
+ },
1136
+ };
1137
+
1138
+ $(document).ready(function () {
1139
+ Wick.Responsive.onResize(function () {
1140
+ $(Wick.BloomreachWidget.el.widgetContainer).each(function () {
1141
+ const $completeWidget = $(this).find(Wick.BloomreachWidget.el.completeWidget);
1142
+
1143
+ if ($completeWidget.length) {
1144
+ Wick.BloomreachWidget.alignCardBlocks($completeWidget);
1145
+ }
1146
+ });
1147
+ });
1148
+ });