wickes-css2 2.113.0-develop.2 → 2.113.0-develop.5
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/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/basket.min.js +1 -1
- package/build/js/bloomreach-widget.min.js +1 -1
- package/build/js/bundle.min.js +1 -1
- package/build/js/checkout.min.js +1 -1
- package/build/js/emulation.min.js +360 -3222
- package/build/js/general.bundle.min.js +1 -1
- package/build/js/merged-checkout.min.js +1 -1
- package/build/js/page/bloomreach-widget/bloomreach-recommendation-carousel-widget.js +318 -0
- package/build/js/page/bloomreach-widget/bloomreach-widget-core.js +370 -0
- package/build/js/page/bloomreach-widget/bloomreach-widget-tracking.js +16 -13
- package/build/js/page/bloomreach-widget/bloomreach-widget.js +8 -237
- package/build/js/page/bloomreach-widget/complete-your-project/cards.js +308 -0
- package/build/js/page/bloomreach-widget/complete-your-project/config.js +60 -0
- package/build/js/page/bloomreach-widget/complete-your-project/model.js +140 -0
- package/build/js/page/bloomreach-widget/complete-your-project/presenter.js +69 -0
- package/build/js/page/bloomreach-widget/complete-your-project/quantity.js +80 -0
- package/build/js/page/bloomreach-widget/complete-your-project/view.js +179 -0
- package/build/js/page/bloomreach-widget/complete-your-project/widget.js +185 -0
- package/build/js/page/bloomreach-widget/dont-forget-widget.js +15 -0
- package/build/js/page/bloomreach-widget/why-not-add-widget.js +10 -228
- package/build/js/pdp.bundle.min.js +1 -1
- package/build/js/plp.bundle.min.js +1 -1
- package/build/js/project-list.min.js +1 -1
- package/package.json +1 -1
- package/src/components/base/button.hbs +7 -0
- package/src/components/bloomreach/complete-your-project-skeleton.hbs +21 -0
- package/src/components/bloomreach/complete-your-project.hbs +6 -21
- package/src/components/bloomreach/why-not-add-card-skeleton.hbs +2 -2
- package/src/components/bloomreach/why-not-add-card.hbs +79 -60
- package/src/components/bloomreach/why-not-add-content.hbs +3 -3
- package/src/components/bloomreach/why-not-add.hbs +1 -1
- package/src/js/components/general/cart-slider.js +41 -4
- package/src/js/emulation/complete-your-project-loading.js +16 -0
- package/src/js/emulation/custom-slider-emulation.js +21 -8
- package/src/js/emulation/dont-forget-loading.js +36 -0
- package/src/js/emulation/just-added-scenarios-emulation.js +131 -0
- package/src/js/emulation/mini-basket.js +34 -34
- package/src/js/emulation/mock.js +429 -4
- package/src/js/emulation/why-not-add-loading.js +14 -3
- package/src/js/emulation/why-not-add.js +12 -14
- package/src/js/page/bloomreach-widget/bloomreach-recommendation-carousel-widget.js +318 -0
- package/src/js/page/bloomreach-widget/bloomreach-widget-core.js +370 -0
- package/src/js/page/bloomreach-widget/bloomreach-widget-tracking.js +16 -13
- package/src/js/page/bloomreach-widget/bloomreach-widget.js +8 -237
- package/src/js/page/bloomreach-widget/complete-your-project/cards.js +308 -0
- package/src/js/page/bloomreach-widget/complete-your-project/config.js +60 -0
- package/src/js/page/bloomreach-widget/complete-your-project/model.js +140 -0
- package/src/js/page/bloomreach-widget/complete-your-project/presenter.js +69 -0
- package/src/js/page/bloomreach-widget/complete-your-project/quantity.js +80 -0
- package/src/js/page/bloomreach-widget/complete-your-project/view.js +179 -0
- package/src/js/page/bloomreach-widget/complete-your-project/widget.js +185 -0
- package/src/js/page/bloomreach-widget/dont-forget-widget.js +15 -0
- package/src/js/page/bloomreach-widget/why-not-add-widget.js +10 -228
- package/src/page_product-details-with-global-search-v2.html +4 -6
- package/src/page_product-details-with-why-not-add-single.html +1 -1
- package/src/scss/components/bloomreach/_bloomreach.scss +1 -0
- package/src/scss/components/bloomreach/_card-shared.scss +24 -0
- package/src/scss/components/bloomreach/_complete-card.scss +1 -9
- package/src/scss/components/bloomreach/_why-not-add-card.scss +137 -10
- package/src/scss/components/bloomreach/_why-not-add.scss +31 -2
- package/build/js/page/bloomreach-widget/complete-your-project-widget.js +0 -1100
- package/src/js/page/bloomreach-widget/complete-your-project-widget.js +0 -1100
package/package.json
CHANGED
|
@@ -15,6 +15,13 @@
|
|
|
15
15
|
<span class="loading-button__loader d-none">
|
|
16
16
|
{{> loader modifier=loaderModifier}}
|
|
17
17
|
</span>
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
{{#if successIcon}}
|
|
21
|
+
<span class="icon button__icon button__icon--success d-none">
|
|
22
|
+
<i class="{{successIcon}}"></i>
|
|
23
|
+
</span>
|
|
24
|
+
{{/if}}
|
|
18
25
|
{{else}}
|
|
19
26
|
{{#if icon}}
|
|
20
27
|
<i class="{{icon}}"></i>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<div class="complete-widget">
|
|
2
|
+
<h3 class="complete-widget__title text-center">
|
|
3
|
+
{{#if title}}{{title}}{{else}}Complete your project{{/if}}
|
|
4
|
+
</h3>
|
|
5
|
+
|
|
6
|
+
<div class="complete-widget__content" data-complete-widget-content>
|
|
7
|
+
<div class="complete-widget__wrapper">
|
|
8
|
+
{{> bloomreach/complete-card-skeleton}}
|
|
9
|
+
|
|
10
|
+
<div class="complete-widget__divider">
|
|
11
|
+
<i class="fal fa-plus"></i>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
{{> bloomreach/complete-card-skeleton}}
|
|
15
|
+
{{> bloomreach/complete-card-skeleton}}
|
|
16
|
+
{{> bloomreach/complete-card-skeleton}}
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
{{> bloomreach/complete-summary-skeleton}}
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
@@ -1,21 +1,6 @@
|
|
|
1
|
-
<div
|
|
2
|
-
|
|
3
|
-
{{#if
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<div class="complete-widget__wrapper">
|
|
8
|
-
{{> bloomreach/complete-card-skeleton}}
|
|
9
|
-
|
|
10
|
-
<div class="complete-widget__divider">
|
|
11
|
-
<i class="fal fa-plus"></i>
|
|
12
|
-
</div>
|
|
13
|
-
|
|
14
|
-
{{> bloomreach/complete-card-skeleton}}
|
|
15
|
-
{{> bloomreach/complete-card-skeleton}}
|
|
16
|
-
{{> bloomreach/complete-card-skeleton}}
|
|
17
|
-
</div>
|
|
18
|
-
|
|
19
|
-
{{> bloomreach/complete-summary-skeleton}}
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
1
|
+
<div
|
|
2
|
+
data-complete-widget
|
|
3
|
+
{{#if context}}data-mock-key="{{context}}"{{/if}}
|
|
4
|
+
>
|
|
5
|
+
{{> bloomreach/complete-your-project-skeleton}}
|
|
6
|
+
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<div class="why-not-add-card why-not-add-card--skeleton ssc">
|
|
1
|
+
<div class="why-not-add-card-wrapper why-not-add-card--skeleton ssc">
|
|
2
2
|
<div class="ssc-square why-not-add-card__image"></div>
|
|
3
3
|
|
|
4
4
|
<div class="ssc-line why-not-add-card__skeleton-title"></div>
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
<div class="ssc-line why-not-add-card__skeleton-delivery"></div>
|
|
12
12
|
|
|
13
13
|
<div class="ssc-square why-not-add-card__skeleton-cta"></div>
|
|
14
|
-
</div>
|
|
14
|
+
</div>
|
|
@@ -1,73 +1,92 @@
|
|
|
1
|
-
<div class="why-not-add-card
|
|
2
|
-
{{
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
<div class="why-not-add-card-wrapper">
|
|
2
|
+
<div class="why-not-add-card" data-product-code="{{code}}">
|
|
3
|
+
{{#if showBadge}}
|
|
4
|
+
{{#if badge.text}}
|
|
5
|
+
<div
|
|
6
|
+
class="why-not-add-card__badge"
|
|
7
|
+
style="background-color: {{badge.color}}; color: {{badge.textColor}};"
|
|
8
|
+
>
|
|
9
|
+
{{badge.text}}
|
|
10
|
+
</div>
|
|
11
|
+
{{/if}}
|
|
12
|
+
{{/if}}
|
|
13
|
+
{{#if image.url}}
|
|
14
|
+
<img
|
|
15
|
+
class="why-not-add-card__image"
|
|
16
|
+
src="{{image.url}}"
|
|
17
|
+
alt="{{image.altText}}"
|
|
18
|
+
>
|
|
19
|
+
{{/if}}
|
|
9
20
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
21
|
+
<div class="why-not-add-card__content">
|
|
22
|
+
<a href="{{url}}" target="_blank" class="why-not-add-card__title">
|
|
23
|
+
{{name}}
|
|
24
|
+
</a>
|
|
14
25
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
{{> reviews-rating
|
|
27
|
+
externalAverageRating=externalAverageRating
|
|
28
|
+
externalReviewCount=externalReviewCount
|
|
29
|
+
}}
|
|
19
30
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
<div class="why-not-add-card__bottom">
|
|
32
|
+
<div class="why-not-add-card__price-wrap">
|
|
33
|
+
<div class="why-not-add-card__price {{#if wasPriceFormatted}}why-not-add-card__price--sale{{/if}}">
|
|
34
|
+
{{#if wasPriceFormatted}}
|
|
35
|
+
<span class="why-not-add-card__was-price">
|
|
36
|
+
{{#if switch-vat}}
|
|
37
|
+
<span class="including-vat-inherit">{{incVatWasPriceFormatted}}</span>
|
|
27
38
|
<span class="excluding-vat-inherit">{{excVatWasPriceFormatted}}</span>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
{{else}}
|
|
40
|
+
{{wasPriceFormatted}}
|
|
41
|
+
{{/if}}
|
|
42
|
+
</span>
|
|
32
43
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
44
|
+
<span class="why-not-add-card__sale-price">
|
|
45
|
+
{{#if switch-vat}}
|
|
46
|
+
<span class="including-vat-inherit">{{incVatFormattedValue}}</span>
|
|
36
47
|
<span class="excluding-vat-inherit">{{excVatFormattedValue}}</span>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
{{else}}
|
|
49
|
+
{{price.formattedValue}}
|
|
50
|
+
{{/if}}
|
|
51
|
+
</span>
|
|
52
|
+
{{else}}
|
|
53
|
+
<span class="why-not-add-card__regular-price">
|
|
54
|
+
{{#if switch-vat}}
|
|
55
|
+
<span class="including-vat-inherit">{{incVatFormattedValue}}</span>
|
|
45
56
|
<span class="excluding-vat-inherit">{{excVatFormattedValue}}</span>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
{{else}}
|
|
58
|
+
{{price.formattedValue}}
|
|
59
|
+
{{/if}}
|
|
60
|
+
</span>
|
|
61
|
+
{{/if}}
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
{{#if switch-vat}}
|
|
65
|
+
<div class="why-not-add-card__vat-label">
|
|
66
|
+
<span class="including-vat-inherit">Inc.VAT</span>
|
|
67
|
+
<span class="excluding-vat-inherit">Exc.VAT</span>
|
|
68
|
+
</div>
|
|
50
69
|
{{/if}}
|
|
51
|
-
</div>
|
|
52
70
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
<span class="including-vat-inherit">Inc.VAT</span>
|
|
56
|
-
<span class="excluding-vat-inherit">Exc.VAT</span>
|
|
57
|
-
</div>
|
|
58
|
-
{{/if}}
|
|
71
|
+
<div class="why-not-add-card__delivery">Excluding delivery</div>
|
|
72
|
+
</div>
|
|
59
73
|
|
|
60
|
-
|
|
74
|
+
{{> button
|
|
75
|
+
type="button"
|
|
76
|
+
action=true
|
|
77
|
+
icon="fas fa-shopping-basket"
|
|
78
|
+
successIcon="fas fa-check"
|
|
79
|
+
showLoader=true
|
|
80
|
+
loaderModifier="why-not-add-card__loader"
|
|
81
|
+
modification="why-not-add-card__cta"
|
|
82
|
+
}}
|
|
61
83
|
</div>
|
|
62
|
-
|
|
63
|
-
{{> button
|
|
64
|
-
type="button"
|
|
65
|
-
action=true
|
|
66
|
-
icon="fas fa-shopping-basket"
|
|
67
|
-
showLoader=true
|
|
68
|
-
loaderModifier="why-not-add-card__loader"
|
|
69
|
-
modification="why-not-add-card__cta"
|
|
70
|
-
}}
|
|
71
84
|
</div>
|
|
72
85
|
</div>
|
|
73
|
-
|
|
86
|
+
{{#if addToCartError}}
|
|
87
|
+
<div class="why-not-add-card__error d-none">
|
|
88
|
+
<i class="icon fas fa-times-circle fa-w-16"></i>
|
|
89
|
+
<span data-add-to-cart-error>{{addToCartError}}</span>
|
|
90
|
+
</div>
|
|
91
|
+
{{/if}}
|
|
92
|
+
</div>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
<div class="why-not-add {{#if isSingleProduct}}why-not-add--single{{/if}}" data-why-not-add>
|
|
1
|
+
<div class="why-not-add {{modifier}} {{#if isSingleProduct}}why-not-add--single{{/if}}" data-why-not-add>
|
|
2
2
|
<div class="why-not-add__header">
|
|
3
|
-
<h3 class="why-not-add__title">
|
|
3
|
+
<h3 class="why-not-add__title">{{title}}</h3>
|
|
4
4
|
|
|
5
5
|
{{#unless isSingleProduct}}
|
|
6
6
|
<div class="why-not-add__arrows">
|
|
@@ -38,4 +38,4 @@
|
|
|
38
38
|
{{#unless isSingleProduct}}
|
|
39
39
|
<div class="why-not-add__pagination" data-why-not-add-pagination></div>
|
|
40
40
|
{{/unless}}
|
|
41
|
-
</div>
|
|
41
|
+
</div>
|
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
const cartSliderHTML = '<div class="custom-slider just-added d-none"></div>';
|
|
2
2
|
|
|
3
|
+
function waitUntilVisible($element, callback) {
|
|
4
|
+
if (!$element.length) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const element = $element[0];
|
|
9
|
+
const rect = element.getBoundingClientRect();
|
|
10
|
+
|
|
11
|
+
if (rect.width > 0 && rect.height > 0) {
|
|
12
|
+
callback();
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const observer = new ResizeObserver(function (entries) {
|
|
17
|
+
const { width, height } = entries[0].contentRect;
|
|
18
|
+
|
|
19
|
+
if (width > 0 && height > 0) {
|
|
20
|
+
observer.disconnect();
|
|
21
|
+
callback();
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
observer.observe(element);
|
|
26
|
+
}
|
|
27
|
+
|
|
3
28
|
createPopupSlider({
|
|
4
29
|
type: 'cart',
|
|
5
30
|
sliderSelector: '.custom-slider.just-added',
|
|
@@ -15,16 +40,28 @@ createPopupSlider({
|
|
|
15
40
|
$('body').append(cartSliderHTML);
|
|
16
41
|
}
|
|
17
42
|
|
|
18
|
-
const
|
|
43
|
+
const $slider = $('.custom-slider.just-added').last();
|
|
44
|
+
const htmlContent = event.detail.cartPopupHtml || event.detail.html;
|
|
19
45
|
|
|
20
46
|
if (htmlContent) {
|
|
21
|
-
$
|
|
47
|
+
$slider.append(htmlContent);
|
|
22
48
|
}
|
|
23
49
|
|
|
50
|
+
const $sliderWrap = $slider.find('.custom-slider__wrap').last();
|
|
51
|
+
const dontForgetPayload = event.detail.recommendationWidget;
|
|
52
|
+
|
|
24
53
|
showSlider();
|
|
25
54
|
|
|
26
|
-
if ($
|
|
27
|
-
$(
|
|
55
|
+
if ($sliderWrap.length && Wick.BloomreachWidget?.hasRecommendations(dontForgetPayload)) {
|
|
56
|
+
waitUntilVisible($slider, function () {
|
|
57
|
+
Wick.BloomreachWidget.init('dontForget', dontForgetPayload, {
|
|
58
|
+
container: $sliderWrap,
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if ($sliderWrap.length) {
|
|
64
|
+
$sliderWrap.on(
|
|
28
65
|
'scroll',
|
|
29
66
|
_.debounce(() => handleScroll(el.sliderWrap), 100)
|
|
30
67
|
);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var Wick = window.Wick || {};
|
|
2
|
+
|
|
3
|
+
$(document).ready(function () {
|
|
4
|
+
const $container = $('[data-complete-widget]');
|
|
5
|
+
|
|
6
|
+
if (!$container.length) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
window.setTimeout(function () {
|
|
11
|
+
const mockDataKey = $container.data('mock-key');
|
|
12
|
+
const payloadData = Wick.FEMock.dataBloomreach[mockDataKey];
|
|
13
|
+
|
|
14
|
+
Wick.BloomreachWidget.init('completeYourProject', payloadData);
|
|
15
|
+
}, 3000);
|
|
16
|
+
});
|
|
@@ -1,21 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var Wick = window.Wick || {};
|
|
2
|
+
|
|
3
|
+
import { getNextCartAddScenario, dispatchCartScenario } from './just-added-scenarios-emulation';
|
|
4
|
+
|
|
5
|
+
function getCartMock() {
|
|
6
|
+
const cartMockKey = $('.pdp__main').data('cart-mock-key') || 'cartPDP';
|
|
7
|
+
|
|
8
|
+
return Wick.FEMock[cartMockKey];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function simulateHybrisSendingHtml(event) {
|
|
12
|
+
event.preventDefault();
|
|
13
|
+
|
|
14
|
+
const scenario = getNextCartAddScenario();
|
|
15
|
+
const cartMock = getCartMock();
|
|
16
|
+
|
|
17
|
+
dispatchCartScenario(cartMock, scenario);
|
|
7
18
|
}
|
|
8
19
|
|
|
9
20
|
function bindResolveEvent(events) {
|
|
10
21
|
$(window).on(events.join(' '), function ({ detail: { resolve } }) {
|
|
11
|
-
setTimeout(()
|
|
22
|
+
setTimeout(function () {
|
|
12
23
|
resolve();
|
|
13
24
|
}, 200);
|
|
14
25
|
});
|
|
15
26
|
}
|
|
16
27
|
|
|
17
28
|
$(document).ready(function () {
|
|
18
|
-
$(
|
|
29
|
+
$(document)
|
|
30
|
+
.off('click.customSliderEmulation', '.btn-add-to-basket')
|
|
31
|
+
.on('click.customSliderEmulation', '.btn-add-to-basket', simulateHybrisSendingHtml);
|
|
19
32
|
|
|
20
33
|
bindResolveEvent([
|
|
21
34
|
'CLOSE_JUST_ADDED',
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var Wick = window.Wick || {};
|
|
2
|
+
|
|
3
|
+
let shouldFailNext = false;
|
|
4
|
+
|
|
5
|
+
const RESPONSE_MESSAGES = {
|
|
6
|
+
success: {
|
|
7
|
+
messageType: 'success',
|
|
8
|
+
messageText: 'Item added to cart',
|
|
9
|
+
},
|
|
10
|
+
error: {
|
|
11
|
+
messageType: 'error',
|
|
12
|
+
messageText: 'Product has not been added to basket',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function bindDontForgetAddToCartEvent() {
|
|
17
|
+
$(window)
|
|
18
|
+
.off('addToCart.dontForgetEmulation')
|
|
19
|
+
.on('addToCart.dontForgetEmulation', function ({ detail = {} }) {
|
|
20
|
+
const { payload, resolve } = detail;
|
|
21
|
+
|
|
22
|
+
if (!payload || payload.doNotShowAddedProductPopup !== true) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
shouldFailNext = !shouldFailNext;
|
|
27
|
+
|
|
28
|
+
window.setTimeout(function () {
|
|
29
|
+
resolve(shouldFailNext ? RESPONSE_MESSAGES.error : RESPONSE_MESSAGES.success);
|
|
30
|
+
}, 2000);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
$(document).ready(function () {
|
|
35
|
+
bindDontForgetAddToCartEvent();
|
|
36
|
+
});
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
var Wick = window.Wick || {};
|
|
2
|
+
|
|
3
|
+
const cartAddScenarios = [
|
|
4
|
+
{
|
|
5
|
+
status: 'SUCCESS',
|
|
6
|
+
icon: 'fas fa-check-circle',
|
|
7
|
+
iconClass: 'success',
|
|
8
|
+
message: "You've just added",
|
|
9
|
+
description: 'Excluding items already in basket',
|
|
10
|
+
showDontForget: true,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
status: 'PARTIAL_INSUFFICIENT_STOCK',
|
|
14
|
+
icon: 'fas fa-exclamation-circle',
|
|
15
|
+
iconClass: 'warning',
|
|
16
|
+
message:
|
|
17
|
+
'A lower quantity of this product has been added to your Basket due to insufficient stock',
|
|
18
|
+
description: '',
|
|
19
|
+
showDontForget: true,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
status: 'PARTIAL_MAX_QTY',
|
|
23
|
+
icon: 'fas fa-exclamation-circle',
|
|
24
|
+
iconClass: 'warning',
|
|
25
|
+
message: 'A lower quantity of product(s) was added to the basket',
|
|
26
|
+
description:
|
|
27
|
+
'We are only able to fulfil a maximum of 30 Blue Circle Ready To Use Postcrete - 20kg per order',
|
|
28
|
+
showDontForget: true,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
status: 'MAX_QTY_ERROR',
|
|
32
|
+
icon: 'fas fa-times-circle',
|
|
33
|
+
iconClass: 'error',
|
|
34
|
+
message: 'Maximum of 30 Blue Circle Ready To Use Postcrete - 20kg per order',
|
|
35
|
+
description: '',
|
|
36
|
+
showDontForget: true,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
status: 'MIN_QTY_ERROR',
|
|
40
|
+
icon: 'fas fa-times-circle',
|
|
41
|
+
iconClass: 'error',
|
|
42
|
+
message: 'Minimum of 2 Blue Circle Ready To Use Postcrete - 20kg per order',
|
|
43
|
+
description: '',
|
|
44
|
+
showDontForget: true,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
status: 'PRODUCT_NOT_FOUND',
|
|
48
|
+
icon: 'fas fa-times-circle',
|
|
49
|
+
iconClass: 'error',
|
|
50
|
+
message: 'Unable to add to basket',
|
|
51
|
+
description: 'An error occurred when adding to basket',
|
|
52
|
+
showDontForget: false,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
status: 'INSUFFICIENT_STOCK_ERROR',
|
|
56
|
+
icon: 'fas fa-times-circle',
|
|
57
|
+
iconClass: 'error',
|
|
58
|
+
message: 'Not added to basket due to insufficient stock',
|
|
59
|
+
description: '',
|
|
60
|
+
showDontForget: false,
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
let currentScenarioIndex = 0;
|
|
65
|
+
|
|
66
|
+
export function getNextCartAddScenario() {
|
|
67
|
+
const scenario = cartAddScenarios[currentScenarioIndex];
|
|
68
|
+
|
|
69
|
+
currentScenarioIndex = (currentScenarioIndex + 1) % cartAddScenarios.length;
|
|
70
|
+
|
|
71
|
+
return scenario;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function getMockRecommendationWidget(html) {
|
|
75
|
+
if (!html || !Wick.FEMock || !Wick.FEMock.dataBloomreach) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const $html = $(html);
|
|
80
|
+
const $sliderWrap = $html
|
|
81
|
+
.filter('.custom-slider__wrap')
|
|
82
|
+
.add($html.find('.custom-slider__wrap'))
|
|
83
|
+
.first();
|
|
84
|
+
|
|
85
|
+
const mockDataKey = $sliderWrap.attr('data-mock-key');
|
|
86
|
+
|
|
87
|
+
return mockDataKey ? Wick.FEMock.dataBloomreach[mockDataKey] : null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function createCartScenarioHtml(baseHtml, scenario) {
|
|
91
|
+
const $root = $('<div>').html(baseHtml);
|
|
92
|
+
const $message = $root.find('.custom-slider__message');
|
|
93
|
+
const $notice = $message.find('.messages__notice');
|
|
94
|
+
|
|
95
|
+
$message.find('.icon-wrap').first().replaceWith(`
|
|
96
|
+
<span class="icon-wrap ${scenario.iconClass}">
|
|
97
|
+
<i class="${scenario.icon}"></i>
|
|
98
|
+
</span>
|
|
99
|
+
`);
|
|
100
|
+
|
|
101
|
+
$message.find('.messages__text span').text(scenario.message);
|
|
102
|
+
|
|
103
|
+
if (scenario.description) {
|
|
104
|
+
$notice.text(scenario.description);
|
|
105
|
+
} else {
|
|
106
|
+
$notice.remove();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (!scenario.showDontForget) {
|
|
110
|
+
$root.find('.custom-slider__wrap').removeAttr('data-mock-key');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return $root.html();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function dispatchCartScenario(baseHtml, scenario) {
|
|
117
|
+
const html = createCartScenarioHtml(baseHtml, scenario);
|
|
118
|
+
const recommendationWidget = scenario.showDontForget ? getMockRecommendationWidget(html) : null;
|
|
119
|
+
|
|
120
|
+
window.dispatchEvent(
|
|
121
|
+
new CustomEvent('productAddedToCart', {
|
|
122
|
+
detail: {
|
|
123
|
+
html,
|
|
124
|
+
cartPopupHtml: html,
|
|
125
|
+
addToCartStatus: scenario.status,
|
|
126
|
+
showDontForget: scenario.showDontForget,
|
|
127
|
+
recommendationWidget,
|
|
128
|
+
},
|
|
129
|
+
})
|
|
130
|
+
);
|
|
131
|
+
}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
var Wick = Wick || {};
|
|
2
|
-
Wick.ShoppingCart = (function(){
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function bindEvents() {
|
|
21
|
-
$('.btn-add-to-basket, .page-product-details .card-store-collect__btn').on('click', add);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
var init = function () {
|
|
25
|
-
bindEvents();
|
|
26
|
-
|
|
27
|
-
if(isEmpty()){
|
|
28
|
-
clear();
|
|
29
|
-
} else {
|
|
30
|
-
$btn.find('.header-minicart__counter').addClass('_is-visible');
|
|
2
|
+
Wick.ShoppingCart = (function () {
|
|
3
|
+
var $btn = $('.header-minicart__switcher');
|
|
4
|
+
|
|
5
|
+
function isEmpty() {
|
|
6
|
+
return localStorage.isEmpty === 'true';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function clear() {
|
|
10
|
+
localStorage.isEmpty = true;
|
|
11
|
+
$btn.find('.header-minicart__counter').removeClass('_is-visible');
|
|
12
|
+
Wick.MiniBasket.disableRollover();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function add() {
|
|
16
|
+
localStorage.isEmpty = false;
|
|
17
|
+
$btn.find('.header-minicart__counter').addClass('_is-visible');
|
|
31
18
|
}
|
|
32
|
-
};
|
|
33
19
|
|
|
34
|
-
|
|
20
|
+
function bindEvents() {
|
|
21
|
+
$('.btn-add-to-basket, .page-product-details .card-store-collect__btn').on('click', add);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var init = function () {
|
|
25
|
+
bindEvents();
|
|
26
|
+
|
|
27
|
+
if (isEmpty()) {
|
|
28
|
+
clear();
|
|
29
|
+
} else {
|
|
30
|
+
$btn.find('.header-minicart__counter').addClass('_is-visible');
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
$(document).ready(init);
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
return {
|
|
37
|
+
clear: clear,
|
|
38
|
+
};
|
|
39
39
|
})();
|