wickes-css2 2.106.0-develop.1 → 2.106.0-develop.10
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 +2 -3
- package/build/css/category-main.css +1 -1
- package/build/css/components/checkout-payment-details-v2.css +1 -1
- package/build/css/components/global-search.css +1 -1
- package/build/css/homepage-main.css +1 -1
- package/build/css/kitchen-plp-main.css +1 -1
- package/build/css/main.css +1 -1
- package/build/css/my-account-main-v2.css +1 -1
- package/build/css/my-account-main.css +1 -1
- package/build/css/pages/page_checkout_delivery-new.css +1 -1
- package/build/css/pages/page_products-list-combined.css +1 -1
- package/build/css/pdp-main-before-combine.css +1 -1
- package/build/css/pdp-main-critical.css +1 -1
- package/build/css/pdp-main-non-critical.css +1 -1
- package/build/css/pdp-main.css +1 -1
- package/build/css/plp-main.css +1 -1
- package/build/css/store-locator-main.css +1 -1
- package/build/img/billie-pay-later.svg +13 -0
- package/build/img/giftcard.svg +28 -0
- package/build/js/account-members.min.js +1 -1
- package/build/js/add-project-list-id.min.js +1 -1
- package/build/js/address-book.min.js +1 -1
- package/build/js/basket.min.js +2 -2
- package/build/js/bundle.min.js +1 -1
- package/build/js/change-password.min.js +1 -1
- package/build/js/checkout.min.js +2 -2
- package/build/js/emulation.min.js +2175 -1857
- package/build/js/general.bundle.min.js +1 -1
- package/build/js/gift-cards.min.js +1 -0
- package/build/js/merged-checkout.min.js +2 -2
- package/build/js/mini-basket-slider.min.js +1 -1
- package/build/js/page/basket/basket-update-cart-action.js +4 -1
- package/build/js/page/basket/klarna.js +13 -3
- package/build/js/page/basket-v2.js +11 -7
- package/build/js/page/components/billie-modal.js +20 -20
- package/build/js/page/components/gift-cards.js +927 -0
- package/build/js/page/components/order-summary.js +57 -28
- package/build/js/page/components/toggle-password-visibility.js +22 -0
- package/build/js/page/components/voucher.js +52 -47
- package/build/js/page/count-stepper/pdp-count-stepper.js +29 -0
- package/build/js/page/filters/plp-filters-mobile.js +4 -7
- package/build/js/page/filters/plp-filters-utils.js +9 -0
- package/build/js/page/filters/plp-filters.js +13 -5
- package/build/js/page/kitchen/colour-swatches.js +152 -152
- package/build/js/page/quick-filter.js +106 -103
- package/build/js/page/share-project-list.js +151 -33
- package/build/js/page/utils/create-count-stepper.js +141 -0
- package/build/js/page/utils/gift-cards-utils.js +242 -0
- package/build/js/page/utils/input-handling.js +104 -0
- package/build/js/page/utils/show-hide-input.js +31 -0
- package/build/js/page/utils/validation.js +146 -96
- package/build/js/pdp-count-stepper.min.js +1 -0
- package/build/js/pdp.bundle.min.js +1 -1
- package/build/js/personal-details.min.js +1 -1
- package/build/js/plp-filters.min.js +2 -2
- package/build/js/plp.bundle.min.js +1 -1
- package/build/js/project-list.min.js +57 -14
- package/build/js/quiz.min.js +1 -1
- package/build/js/share-project-list.min.js +1 -1
- package/build/js/track-my-order.min.js +1 -1
- package/package.json +3 -3
- package/src/components/card_product_v2.hbs +6 -1
- package/src/components/checkout-payment-details-v2.hbs +4 -3
- package/src/components/gift-cards-hint.hbs +9 -0
- package/src/components/gift-cards.hbs +90 -0
- package/src/components/giftcard-chip.hbs +23 -0
- package/src/components/giftcard-summary.hbs +6 -0
- package/src/components/home-movers/form.hbs +1 -1
- package/src/components/price-block-v2.hbs +17 -16
- package/src/data/data_search-results_v2.json +2 -1
- package/src/elements/count-button.hbs +10 -0
- package/src/elements/form-row.hbs +1 -1
- package/src/elements/input.hbs +31 -2
- package/src/img/billie-pay-later.svg +13 -0
- package/src/img/giftcard.svg +28 -0
- package/src/js/components/general/notification.js +60 -40
- package/src/js/components/general/switchVat.js +151 -154
- package/src/js/components/pdp-billie-modal-scroll-reset.js +46 -42
- package/src/js/emulation/basket-data.js +2126 -2038
- package/src/js/emulation/billie-modal.js +6 -6
- package/src/js/emulation/checkLocalEnv.js +6 -5
- package/src/js/emulation/checkout-data.js +33 -0
- package/src/js/emulation/checkout-payment-details.js +23 -21
- package/src/js/emulation/forms.js +9 -2
- package/src/js/emulation/gift-cards.js +216 -0
- package/src/js/emulation/mock.js +98 -21
- package/src/js/emulation/plp-load-more.js +19 -13
- package/src/js/emulation/validity-emulation.js +33 -0
- package/src/js/page/basket/basket-update-cart-action.js +4 -1
- package/src/js/page/basket/klarna.js +13 -3
- package/src/js/page/basket-v2.js +11 -7
- package/src/js/page/components/billie-modal.js +20 -20
- package/src/js/page/components/gift-cards.js +927 -0
- package/src/js/page/components/order-summary.js +57 -28
- package/src/js/page/components/toggle-password-visibility.js +22 -0
- package/src/js/page/components/voucher.js +52 -47
- package/src/js/page/count-stepper/pdp-count-stepper.js +29 -0
- package/src/js/page/filters/plp-filters-mobile.js +4 -7
- package/src/js/page/filters/plp-filters-utils.js +9 -0
- package/src/js/page/filters/plp-filters.js +13 -5
- package/src/js/page/kitchen/colour-swatches.js +152 -152
- package/src/js/page/quick-filter.js +106 -103
- package/src/js/page/share-project-list.js +151 -33
- package/src/js/page/utils/create-count-stepper.js +141 -0
- package/src/js/page/utils/gift-cards-utils.js +242 -0
- package/src/js/page/utils/input-handling.js +104 -0
- package/src/js/page/utils/show-hide-input.js +31 -0
- package/src/js/page/utils/validation.js +146 -96
- package/src/layouts/checkout.hbs +1 -5
- package/src/page_my-account_change-password.html +1 -0
- package/src/page_payment-details-with-gift-card.html +8 -5
- package/src/page_plp-with-paint.html +1 -1
- package/src/page_plp_v2-energy-efficiency.html +1 -1
- package/src/page_plp_v2-favourite-products.html +1 -1
- package/src/page_plp_v2-vat.html +31 -26
- package/src/page_plp_v2.html +1 -1
- package/src/page_product-details-cnc-success-notification-vat.html +3 -2
- package/src/page_product_search-vat.html +1 -1
- package/src/page_product_search.html +1 -1
- package/src/page_search-results.html +1 -1
- package/src/partials/scripts.hbs +4 -0
- package/src/scss/components/_custom-slider.scss +7 -6
- package/src/scss/components/_gift-cards.scss +359 -0
- package/src/scss/components/_input-counter.scss +65 -0
- package/src/scss/components/_quick-filter.scss +32 -10
- package/src/scss/components/checkout-payment-details-v2.scss +6 -2
- package/src/scss/components/kitchen/_price-tooltip.scss +3 -2
- package/src/scss/components/kitchen/_price.scss +2 -2
- package/src/scss/helpers/_variables.scss +7 -16
- package/src/scss/pages/page_checkout_delivery-new.scss +30 -6
- package/src/scss/pages/page_products-list-combined.scss +34 -2
- package/src/scss/pdp-main.scss +1 -0
- package/build/js/page/plp-img-v2.js +0 -25
- package/src/components/.DS_Store +0 -0
- package/src/img/.DS_Store +0 -0
- package/src/img/placeholders/.DS_Store +0 -0
- package/src/js/.DS_Store +0 -0
- package/src/js/components/share-project-list.js +0 -56
- package/src/js/components/toggle-password-visibility.js +0 -58
- package/src/js/page/.DS_Store +0 -0
- package/src/js/page/plp-img-v2.js +0 -25
- package/src/scss/.DS_Store +0 -0
- package/src/scss/pages/.DS_Store +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {updateDiscount} from
|
|
1
|
+
import { updateDiscount } from './discounts';
|
|
2
2
|
|
|
3
3
|
const osEl = {
|
|
4
4
|
$summarySection: $('.summary'),
|
|
@@ -10,17 +10,19 @@ const osEl = {
|
|
|
10
10
|
itemDeficit: '.checkout-widget__item-deficit',
|
|
11
11
|
summaryDelivery: '.checkout-widget__item-delivery',
|
|
12
12
|
summaryMobileTotal: '.summary__mobile-bar-total',
|
|
13
|
-
}
|
|
13
|
+
};
|
|
14
14
|
|
|
15
15
|
export function updateOrderSummary(data, equalMap, isVoucher) {
|
|
16
16
|
equalMap.forEach((obj) => {
|
|
17
|
+
if (typeof obj.dataValue === 'undefined') return;
|
|
18
|
+
|
|
17
19
|
if ($(obj.item).length) {
|
|
18
20
|
$(obj.item).show();
|
|
19
21
|
} else {
|
|
20
22
|
if ($(osEl.checkoutWidgetDetailsDiscount).length) {
|
|
21
|
-
$(osEl.checkoutWidgetDetailsDiscount).before(createCheckoutWidgetItem(obj))
|
|
23
|
+
$(osEl.checkoutWidgetDetailsDiscount).before(createCheckoutWidgetItem(obj));
|
|
22
24
|
} else {
|
|
23
|
-
$(osEl.checkoutWidgetDetails).append(createCheckoutWidgetItem(obj))
|
|
25
|
+
$(osEl.checkoutWidgetDetails).append(createCheckoutWidgetItem(obj));
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
|
|
@@ -30,14 +32,35 @@ export function updateOrderSummary(data, equalMap, isVoucher) {
|
|
|
30
32
|
} else {
|
|
31
33
|
$(obj.item).hide();
|
|
32
34
|
}
|
|
33
|
-
})
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const keys = new Set(Object.keys(data || {}));
|
|
38
|
+
const hasAny = (...arr) => arr.some((k) => keys.has(k));
|
|
34
39
|
|
|
35
40
|
const value = data.totalPrice?.formattedValue || data.total;
|
|
41
|
+
if (typeof value !== 'undefined' && hasAny('total', 'totalPrice')) {
|
|
42
|
+
updateSummaryMobileBarTotal(value);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (hasAny('promotionsInfo')) {
|
|
46
|
+
updateDiscount(data, isVoucher);
|
|
47
|
+
}
|
|
36
48
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
49
|
+
if (
|
|
50
|
+
hasAny(
|
|
51
|
+
'deliveryOrder',
|
|
52
|
+
'clickAndCollectOrder',
|
|
53
|
+
'clickAndCollectOnly',
|
|
54
|
+
'deliveryItemsQuantity',
|
|
55
|
+
'pickupItemsQuantity'
|
|
56
|
+
)
|
|
57
|
+
) {
|
|
58
|
+
hideUnusedDeliveryTypeCost(data, isVoucher);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (hasAny('freeDelivery', 'messageForFreeDelivery', 'clickAndCollectOnly')) {
|
|
62
|
+
calculateFreeDelivery(data);
|
|
63
|
+
}
|
|
41
64
|
}
|
|
42
65
|
|
|
43
66
|
function createCheckoutWidgetItem(obj) {
|
|
@@ -46,23 +69,25 @@ function createCheckoutWidgetItem(obj) {
|
|
|
46
69
|
<span>${obj.title}</span>
|
|
47
70
|
<span class="checkout-widget__item-value">${obj.dataValue}</span>
|
|
48
71
|
</li>
|
|
49
|
-
|
|
72
|
+
`;
|
|
50
73
|
}
|
|
51
74
|
|
|
52
75
|
function hideUnusedDeliveryTypeCost(data, isVoucher) {
|
|
53
|
-
$(osEl.delivery).show()
|
|
54
|
-
$(osEl.cc).show()
|
|
76
|
+
$(osEl.delivery).show();
|
|
77
|
+
$(osEl.cc).show();
|
|
55
78
|
if (isVoucher) {
|
|
56
|
-
if (
|
|
57
|
-
$(osEl.delivery).hide()
|
|
58
|
-
}
|
|
59
|
-
|
|
79
|
+
if ('deliveryOrder' in data && data.deliveryOrder === false) {
|
|
80
|
+
$(osEl.delivery).hide();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if ('clickAndCollectOrder' in data && data.clickAndCollectOrder === false) {
|
|
84
|
+
$(osEl.cc).hide();
|
|
60
85
|
}
|
|
61
86
|
} else {
|
|
62
87
|
if (data.clickAndCollectOnly) {
|
|
63
|
-
$(osEl.delivery).hide()
|
|
88
|
+
$(osEl.delivery).hide();
|
|
64
89
|
} else if (data.deliveryItemsQuantity > 0 && data.pickupItemsQuantity === 0) {
|
|
65
|
-
$(osEl.cc).hide()
|
|
90
|
+
$(osEl.cc).hide();
|
|
66
91
|
}
|
|
67
92
|
}
|
|
68
93
|
}
|
|
@@ -73,31 +98,35 @@ function calculateFreeDelivery(data) {
|
|
|
73
98
|
let $deficit = $(this).find(osEl.itemDeficit);
|
|
74
99
|
|
|
75
100
|
!$free.length || $free.remove();
|
|
76
|
-
!$deficit.length || $deficit.remove()
|
|
101
|
+
!$deficit.length || $deficit.remove();
|
|
77
102
|
|
|
78
103
|
if (!data.clickAndCollectOnly) {
|
|
79
104
|
if (data.freeDelivery && data.messageForFreeDelivery) {
|
|
80
|
-
$(this)
|
|
81
|
-
|
|
105
|
+
$(this)
|
|
106
|
+
.find(osEl.summaryDelivery)
|
|
107
|
+
.before(function () {
|
|
108
|
+
return `
|
|
82
109
|
<div class="checkout-widget__item checkout-widget__item-free">
|
|
83
110
|
<span class="checkout-widget__text">
|
|
84
111
|
${data.messageForFreeDelivery}
|
|
85
112
|
</span>
|
|
86
113
|
</div>
|
|
87
|
-
|
|
88
|
-
|
|
114
|
+
`;
|
|
115
|
+
});
|
|
89
116
|
$(this).find(osEl.summaryDelivery).hide();
|
|
90
117
|
} else if (!data.freeDelivery && data.messageForFreeDelivery) {
|
|
91
|
-
$(this)
|
|
92
|
-
|
|
118
|
+
$(this)
|
|
119
|
+
.find(osEl.summaryDelivery)
|
|
120
|
+
.before(function () {
|
|
121
|
+
return `
|
|
93
122
|
<div class="checkout-widget__item checkout-widget__item-deficit">
|
|
94
123
|
${data.messageForFreeDelivery}
|
|
95
124
|
</div>
|
|
96
|
-
|
|
97
|
-
|
|
125
|
+
`;
|
|
126
|
+
});
|
|
98
127
|
}
|
|
99
128
|
}
|
|
100
|
-
})
|
|
129
|
+
});
|
|
101
130
|
}
|
|
102
131
|
|
|
103
132
|
function updateSummaryMobileBarTotal(formattedValue) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { initializeInputToggle } from '../utils/show-hide-input';
|
|
2
|
+
|
|
3
|
+
var Wick = window.Wick || {};
|
|
4
|
+
|
|
5
|
+
Wick.TogglePasswordVisibility = {
|
|
6
|
+
el: {
|
|
7
|
+
$containers: $('.form-row[data-show-content] .input-wrap'),
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
init() {
|
|
11
|
+
if (!this.el.$containers.length) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
this.el.$containers.each(function () {
|
|
15
|
+
initializeInputToggle($(this));
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
$(document).ready(function () {
|
|
21
|
+
Wick.TogglePasswordVisibility.init();
|
|
22
|
+
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {updateOrderSummary} from './order-summary';
|
|
2
|
-
import {callAction} from '../utils/http-action';
|
|
3
|
-
import {retryAction, retryHelpers} from
|
|
4
|
-
import {showValidationErrors} from '../utils/validation'
|
|
5
|
-
import {updateKlarnaPlacements} from '../basket/klarna';
|
|
6
|
-
import {getCSRFToken, CSRF} from
|
|
7
|
-
import {ROUTES} from '../utils/routes';
|
|
8
|
-
import {updateClearpayPlacements, updateClearpayVisibility} from '../basket/clearpay';
|
|
1
|
+
import { updateOrderSummary } from './order-summary';
|
|
2
|
+
import { callAction } from '../utils/http-action';
|
|
3
|
+
import { retryAction, retryHelpers } from './retry-action';
|
|
4
|
+
import { showValidationErrors } from '../utils/validation';
|
|
5
|
+
import { updateKlarnaPlacements } from '../basket/klarna';
|
|
6
|
+
import { getCSRFToken, CSRF } from './csrf';
|
|
7
|
+
import { ROUTES } from '../utils/routes';
|
|
8
|
+
import { updateClearpayPlacements, updateClearpayVisibility } from '../basket/clearpay';
|
|
9
9
|
|
|
10
10
|
const voucherEl = {
|
|
11
11
|
$basketVoucher: $('.checkout-voucher'),
|
|
@@ -30,8 +30,10 @@ const voucherEl = {
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
export function checkVoucherCode(e, current) {
|
|
33
|
-
e && e.preventDefault()
|
|
34
|
-
const context = current
|
|
33
|
+
e && e.preventDefault();
|
|
34
|
+
const context = current
|
|
35
|
+
? $(current).closest(voucherEl.voucher)
|
|
36
|
+
: $(this).closest(voucherEl.voucher),
|
|
35
37
|
value = context.find('input').val().trim(),
|
|
36
38
|
encodedValue = encodeURIComponent(value),
|
|
37
39
|
errorMsg = {
|
|
@@ -39,8 +41,8 @@ export function checkVoucherCode(e, current) {
|
|
|
39
41
|
responseJSON: {
|
|
40
42
|
globalMessage: {
|
|
41
43
|
message: 'Please enter a voucher code',
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
+
},
|
|
45
|
+
},
|
|
44
46
|
};
|
|
45
47
|
|
|
46
48
|
if (value && value.length) {
|
|
@@ -59,7 +61,7 @@ function executionVoucherApplying(value, context) {
|
|
|
59
61
|
url: `${ROUTES.VOUCHER_UPDATE}/${value}`,
|
|
60
62
|
type: 'POST',
|
|
61
63
|
headers: {
|
|
62
|
-
|
|
64
|
+
CSRFToken: CSRF.getToken(),
|
|
63
65
|
},
|
|
64
66
|
retryLimit: retryHelpers.retryLimit,
|
|
65
67
|
error: notApplyVoucher,
|
|
@@ -79,7 +81,7 @@ export function voucherRemove() {
|
|
|
79
81
|
let voucher = $(this).parent(),
|
|
80
82
|
voucherCode = voucher.attr('data-coupon-code');
|
|
81
83
|
voucher.addClass('checkout-widget__voucher-removed').text('Voucher removed');
|
|
82
|
-
voucherRemoveAction(voucherCode, voucher)
|
|
84
|
+
voucherRemoveAction(voucherCode, voucher);
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
function voucherRemoveAction(code) {
|
|
@@ -90,7 +92,7 @@ function voucherRemoveAction(code) {
|
|
|
90
92
|
type: 'DELETE',
|
|
91
93
|
headers: {
|
|
92
94
|
'Content-Type': 'application/json',
|
|
93
|
-
|
|
95
|
+
CSRFToken: CSRF.getToken(),
|
|
94
96
|
},
|
|
95
97
|
error: handleVoucherRemovingError,
|
|
96
98
|
};
|
|
@@ -106,12 +108,11 @@ function formattedTotalPriceWithoutSymbol(val) {
|
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
function executionVoucherRemoving(data) {
|
|
109
|
-
updateOrderSummary(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
updateOrderSummary(data, getEqualMapForVoucherUpdate(data), true);
|
|
112
|
+
updateKlarnaPlacements(
|
|
113
|
+
formattedTotalPriceWithoutSymbol(data.total),
|
|
114
|
+
data.paymentInfos.klarnaPaymentInfo.customPaymentMethodIds
|
|
113
115
|
);
|
|
114
|
-
updateKlarnaPlacements(formattedTotalPriceWithoutSymbol(data.total));
|
|
115
116
|
updateClearpayPlacements(data.total);
|
|
116
117
|
updateClearpayVisibility(data.total);
|
|
117
118
|
}
|
|
@@ -123,19 +124,18 @@ function applyVoucher(data, context) {
|
|
|
123
124
|
|
|
124
125
|
clearValidationErrors($voucherForm);
|
|
125
126
|
voucherEl.$basketVoucher.toggle(voucherEl.voucherHide);
|
|
126
|
-
updateOrderSummary(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
updateOrderSummary(data, getEqualMapForVoucherUpdate(data), true);
|
|
128
|
+
updateKlarnaPlacements(
|
|
129
|
+
formattedTotalPriceWithoutSymbol(data.total),
|
|
130
|
+
data.paymentInfos.klarnaPaymentInfo.customPaymentMethodIds
|
|
130
131
|
);
|
|
131
|
-
updateKlarnaPlacements(formattedTotalPriceWithoutSymbol(data.total));
|
|
132
132
|
updateClearpayPlacements(data.total);
|
|
133
133
|
updateClearpayVisibility(data.total);
|
|
134
134
|
setTimeout(function () {
|
|
135
135
|
voucherButton.attr('disabled', false);
|
|
136
136
|
$voucherFormInput.val('');
|
|
137
137
|
voucherEl.$basketVoucher.toggle(voucherEl.voucherHide);
|
|
138
|
-
}, 5000)
|
|
138
|
+
}, 5000);
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
function notApplyVoucher(xhr, context) {
|
|
@@ -158,21 +158,25 @@ function notApplyVoucher(xhr, context) {
|
|
|
158
158
|
function retryVoucherAction(voucherForm) {
|
|
159
159
|
return new Promise((resolve) => {
|
|
160
160
|
getCSRFToken(resolve);
|
|
161
|
-
}).then(() => {
|
|
162
|
-
retryAction(checkVoucherCode, retryHelpers.retryLimit, ...Array(1), voucherForm)
|
|
163
|
-
}).catch(() => {
|
|
164
|
-
showDefaultError();
|
|
165
161
|
})
|
|
162
|
+
.then(() => {
|
|
163
|
+
retryAction(checkVoucherCode, retryHelpers.retryLimit, ...Array(1), voucherForm);
|
|
164
|
+
})
|
|
165
|
+
.catch(() => {
|
|
166
|
+
showDefaultError();
|
|
167
|
+
});
|
|
166
168
|
}
|
|
167
169
|
|
|
168
170
|
function retryVoucherRemoving(code) {
|
|
169
171
|
return new Promise((resolve) => {
|
|
170
172
|
getCSRFToken(resolve);
|
|
171
|
-
}).then(() => {
|
|
172
|
-
retryAction(voucherRemoveAction, retryHelpers.retryLimit, code);
|
|
173
|
-
}).catch(() => {
|
|
174
|
-
console.log('remove failed');
|
|
175
173
|
})
|
|
174
|
+
.then(() => {
|
|
175
|
+
retryAction(voucherRemoveAction, retryHelpers.retryLimit, code);
|
|
176
|
+
})
|
|
177
|
+
.catch(() => {
|
|
178
|
+
console.log('remove failed');
|
|
179
|
+
});
|
|
176
180
|
}
|
|
177
181
|
|
|
178
182
|
function handleVoucherRemovingError(xhr, code) {
|
|
@@ -182,7 +186,7 @@ function handleVoucherRemovingError(xhr, code) {
|
|
|
182
186
|
}
|
|
183
187
|
|
|
184
188
|
function showDefaultError(error = retryHelpers.errorMsg) {
|
|
185
|
-
const voucher = getNotAppliedVoucher()
|
|
189
|
+
const voucher = getNotAppliedVoucher();
|
|
186
190
|
showValidationErrors(voucher.find('form'), error);
|
|
187
191
|
}
|
|
188
192
|
|
|
@@ -195,9 +199,12 @@ function getNotAppliedVoucher() {
|
|
|
195
199
|
function clearValidationErrors(form) {
|
|
196
200
|
var $form = $(form);
|
|
197
201
|
if ($form.hasClass(voucherEl.formInvalid)) {
|
|
198
|
-
$form
|
|
199
|
-
.
|
|
200
|
-
.find(voucherEl.
|
|
202
|
+
$form
|
|
203
|
+
.removeClass(voucherEl.formInvalid)
|
|
204
|
+
.find(voucherEl.fieldRow)
|
|
205
|
+
.removeClass(voucherEl.rowValidationError)
|
|
206
|
+
.find(voucherEl.fieldError)
|
|
207
|
+
.remove();
|
|
201
208
|
}
|
|
202
209
|
}
|
|
203
210
|
|
|
@@ -207,48 +214,46 @@ function getEqualMapForVoucherUpdate(data) {
|
|
|
207
214
|
item: voucherEl.subtotal,
|
|
208
215
|
itemValue: voucherEl.value,
|
|
209
216
|
dataValue: data.subTotal,
|
|
210
|
-
title: 'Items subtotal:'
|
|
211
|
-
|
|
217
|
+
title: 'Items subtotal:',
|
|
212
218
|
},
|
|
213
219
|
{
|
|
214
220
|
item: voucherEl.vat,
|
|
215
221
|
itemValue: voucherEl.value,
|
|
216
222
|
dataValue: data.vat,
|
|
217
|
-
title: 'VAT:'
|
|
223
|
+
title: 'VAT:',
|
|
218
224
|
},
|
|
219
225
|
{
|
|
220
226
|
item: voucherEl.cc,
|
|
221
227
|
itemValue: voucherEl.value,
|
|
222
228
|
dataValue: data.clickAndCollectCost,
|
|
223
|
-
title: 'Click & Collect:'
|
|
229
|
+
title: 'Click & Collect:',
|
|
224
230
|
},
|
|
225
231
|
{
|
|
226
232
|
item: voucherEl.delivery,
|
|
227
233
|
itemValue: voucherEl.value,
|
|
228
234
|
dataValue: data.deliveryCost,
|
|
229
|
-
title: 'Delivery:'
|
|
235
|
+
title: 'Delivery:',
|
|
230
236
|
},
|
|
231
237
|
{
|
|
232
238
|
item: voucherEl.charity,
|
|
233
239
|
itemValue: voucherEl.value,
|
|
234
240
|
dataValue: data.charityPrice,
|
|
235
|
-
title: 'Charity donation:'
|
|
241
|
+
title: 'Charity donation:',
|
|
236
242
|
},
|
|
237
243
|
{
|
|
238
244
|
item: voucherEl.discountItem,
|
|
239
245
|
itemValue: voucherEl.discountValue,
|
|
240
|
-
dataValue: data.discountTotal
|
|
246
|
+
dataValue: data.discountTotal,
|
|
241
247
|
},
|
|
242
248
|
{
|
|
243
249
|
item: voucherEl.orderTotal,
|
|
244
250
|
itemValue: voucherEl.orderTotalValue,
|
|
245
|
-
dataValue: data.total
|
|
251
|
+
dataValue: data.total,
|
|
246
252
|
},
|
|
247
253
|
];
|
|
248
254
|
}
|
|
249
255
|
|
|
250
256
|
$(document).ready(function () {
|
|
251
|
-
|
|
252
257
|
function init() {
|
|
253
258
|
if (!$('.checkout-voucher').length) {
|
|
254
259
|
return;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createCountStepper } from '../utils/create-count-stepper';
|
|
2
|
+
|
|
3
|
+
var Wick = window.Wick || {};
|
|
4
|
+
|
|
5
|
+
Wick.PDPCountStepper = {
|
|
6
|
+
el: {
|
|
7
|
+
input: '#quantity-field',
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
stepper: null,
|
|
11
|
+
|
|
12
|
+
init() {
|
|
13
|
+
Wick.PDPCountStepper.stepper = createCountStepper({
|
|
14
|
+
inputSel: Wick.PDPCountStepper.el.input,
|
|
15
|
+
min: 1,
|
|
16
|
+
max: 99,
|
|
17
|
+
onChange(qty, inputEl) {
|
|
18
|
+
$(inputEl).trigger('change');
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
Wick.PDPCountStepper.stepper.init($(document));
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
$(document).ready(function () {
|
|
27
|
+
if (!$(Wick.PDPCountStepper.el.input).length) return;
|
|
28
|
+
Wick.PDPCountStepper.init();
|
|
29
|
+
});
|
|
@@ -65,11 +65,6 @@ Wick.PLPFiltersMobile = {
|
|
|
65
65
|
$btn.text(total > 0 ? `View results (${total})` : 'View results');
|
|
66
66
|
},
|
|
67
67
|
|
|
68
|
-
hideAccordions() {
|
|
69
|
-
$(Wick.PLPFiltersMobile.$ACCORDION).addClass(Wick.PLPFiltersMobile.ACCORDION_COLLAPSED);
|
|
70
|
-
$(Wick.PLPFiltersMobile.$ACCORDION_CONTENT).hide();
|
|
71
|
-
},
|
|
72
|
-
|
|
73
68
|
init() {
|
|
74
69
|
// two-way binding for input between desktop and modal
|
|
75
70
|
$(document)
|
|
@@ -86,13 +81,14 @@ Wick.PLPFiltersMobile = {
|
|
|
86
81
|
$(document)
|
|
87
82
|
.off('shown.bs.modal.plpFiltersMobile', Wick.PLPFiltersMobile.MODAL_SEL)
|
|
88
83
|
.on('shown.bs.modal.plpFiltersMobile', Wick.PLPFiltersMobile.MODAL_SEL, function () {
|
|
89
|
-
Wick.PLPFilters.setDOMFromState($(this), Wick.PLPFilters.
|
|
84
|
+
Wick.PLPFilters.setDOMFromState($(this), Wick.PLPFilters.draftState);
|
|
90
85
|
});
|
|
91
86
|
|
|
92
87
|
$(document)
|
|
93
88
|
.off('hide.bs.modal.plpFiltersMobile', Wick.PLPFiltersMobile.MODAL_SEL)
|
|
94
89
|
.on('hide.bs.modal.plpFiltersMobile', Wick.PLPFiltersMobile.MODAL_SEL, function () {
|
|
95
|
-
Wick.PLPFiltersMobile.
|
|
90
|
+
const scope = $(Wick.PLPFiltersMobile.ROOT_WRAPPER).add($(this));
|
|
91
|
+
Wick.PLPFilters.draftState = Wick.PLPFilters.collectStateFromDOM(scope);
|
|
96
92
|
});
|
|
97
93
|
|
|
98
94
|
// mobile "View results" button in modal
|
|
@@ -126,6 +122,7 @@ Wick.PLPFiltersMobile = {
|
|
|
126
122
|
|
|
127
123
|
e.preventDefault();
|
|
128
124
|
|
|
125
|
+
Wick.PLPFilters.draftState = {};
|
|
129
126
|
Wick.PLPFilters.appliedState = {};
|
|
130
127
|
Wick.PLPFilters.writeStateToURL(Wick.PLPFilters.appliedState, false);
|
|
131
128
|
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
var Wick = window.Wick || {};
|
|
2
2
|
|
|
3
3
|
Wick.PLPUtils = (function () {
|
|
4
|
+
function cloneState(state) {
|
|
5
|
+
const out = {};
|
|
6
|
+
Object.keys(state).forEach((k) => {
|
|
7
|
+
out[k] = new Set(state[k]);
|
|
8
|
+
});
|
|
9
|
+
return out;
|
|
10
|
+
}
|
|
11
|
+
|
|
4
12
|
function syncTwinInputsByName(name, checked, source) {
|
|
5
13
|
const all = $('.filter-card__checkbox, .swatch__checkbox, .checkbox__input').filter(
|
|
6
14
|
function () {
|
|
@@ -57,6 +65,7 @@ Wick.PLPUtils = (function () {
|
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
return {
|
|
68
|
+
cloneState,
|
|
60
69
|
syncTwinInputsByName,
|
|
61
70
|
getPanelType,
|
|
62
71
|
countItems,
|
|
@@ -6,6 +6,7 @@ Wick.PLPFilters = {
|
|
|
6
6
|
ROOT: '.plp-filters',
|
|
7
7
|
GROUP: '.plp-filters__group',
|
|
8
8
|
APPLY_BTN: '.plp-filters__apply',
|
|
9
|
+
draftState: null,
|
|
9
10
|
|
|
10
11
|
INPUTS: '.filter-card__checkbox, .swatch__checkbox, .checkbox__input',
|
|
11
12
|
|
|
@@ -24,6 +25,7 @@ Wick.PLPFilters = {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
Wick.PLPFilters.appliedState = Wick.PLPFilters.readStateFromURL(rootWrapper);
|
|
28
|
+
Wick.PLPFilters.draftState = Wick.PLPUtils.cloneState(Wick.PLPFilters.appliedState);
|
|
27
29
|
Wick.PLPFilters.setDOMFromState(rootWrapper, Wick.PLPFilters.appliedState);
|
|
28
30
|
|
|
29
31
|
// 3) chips
|
|
@@ -34,17 +36,20 @@ Wick.PLPFilters = {
|
|
|
34
36
|
|
|
35
37
|
// 5) primary render
|
|
36
38
|
Wick.PLPFilters.updateSelectedUI(rootWrapper);
|
|
37
|
-
|
|
39
|
+
|
|
38
40
|
// 6) handle browser back/forward navigation
|
|
39
41
|
Wick.PLPFilters.handlePageShow();
|
|
40
42
|
},
|
|
41
43
|
|
|
42
44
|
// Handle bfcache (back/forward cache)
|
|
43
45
|
handlePageShow() {
|
|
44
|
-
window.addEventListener('pageshow', function(
|
|
46
|
+
window.addEventListener('pageshow', function () {
|
|
45
47
|
const rootWrapper = $(Wick.PLPFilters.ROOT_WRAPPER);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
const stateScope = rootWrapper.add($(Wick.PLPFiltersMobile.MODAL_SEL));
|
|
49
|
+
|
|
50
|
+
Wick.PLPFilters.appliedState = Wick.PLPFilters.readStateFromURL(stateScope);
|
|
51
|
+
Wick.PLPFilters.draftState = Wick.PLPFilters.appliedState;
|
|
52
|
+
Wick.PLPFilters.setDOMFromState(stateScope, Wick.PLPFilters.appliedState);
|
|
48
53
|
});
|
|
49
54
|
},
|
|
50
55
|
|
|
@@ -187,7 +192,10 @@ Wick.PLPFilters = {
|
|
|
187
192
|
|
|
188
193
|
// ===== APPLY
|
|
189
194
|
applyFromScopes(scopeForCollect, push) {
|
|
190
|
-
|
|
195
|
+
const nextState = Wick.PLPFilters.collectStateFromDOM(scopeForCollect);
|
|
196
|
+
|
|
197
|
+
Wick.PLPFilters.draftState = nextState;
|
|
198
|
+
Wick.PLPFilters.appliedState = nextState;
|
|
191
199
|
Wick.PLPFilters.writeStateToURL(Wick.PLPFilters.appliedState, !!push);
|
|
192
200
|
},
|
|
193
201
|
|