wickes-css2 2.109.0-develop.2 → 2.109.0-gift-cards.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 (44) hide show
  1. package/Readme.md +1 -2
  2. package/build/css/category-main.css +1 -1
  3. package/build/css/components/checkout-payment-details-v2.css +1 -1
  4. package/build/css/homepage-main.css +1 -1
  5. package/build/css/kitchen-plp-main.css +1 -1
  6. package/build/css/main.css +1 -1
  7. package/build/css/my-account-main-v2.css +1 -1
  8. package/build/css/my-account-main.css +1 -1
  9. package/build/css/pages/checkout-new.css +1 -1
  10. package/build/css/pages/checkout.css +1 -1
  11. package/build/css/pdp-main-before-combine.css +1 -1
  12. package/build/css/pdp-main-non-critical.css +1 -1
  13. package/build/css/pdp-main.css +1 -1
  14. package/build/css/plp-main.css +1 -1
  15. package/build/css/store-locator-main.css +1 -1
  16. package/build/img/payment/checkout/giftcard.svg +28 -0
  17. package/build/img/payment/footer/giftcard.svg +28 -0
  18. package/build/js/gift-cards.min.js +1 -1
  19. package/build/js/page/checkout-payment-details.js +176 -79
  20. package/build/js/page/components/gift-cards.js +701 -357
  21. package/build/js/toggle-password-visibility.min.js +1 -0
  22. package/package.json +1 -1
  23. package/src/components/checkout_order-summary-new.hbs +6 -0
  24. package/src/components/checkout_payment-new.hbs +31 -8
  25. package/src/components/gift-cards.hbs +8 -15
  26. package/src/components/payments.hbs +6 -5
  27. package/src/data/data_checkout-giftcards.json +7 -0
  28. package/src/data/data_delivery-address-v2.json +4 -0
  29. package/src/data/data_payments-checkout.json +4 -0
  30. package/src/data/footer_menu.json +4 -0
  31. package/src/img/payment/checkout/giftcard.svg +28 -0
  32. package/src/img/payment/footer/giftcard.svg +28 -0
  33. package/src/js/page/checkout-payment-details.js +176 -79
  34. package/src/js/page/components/gift-cards.js +701 -357
  35. package/src/page_checkout_confirmation-gift-card.html +339 -0
  36. package/src/page_payment-details-with-gift-card.html +1 -1
  37. package/src/page_product-details-billie.html +2 -0
  38. package/src/page_product-details-clearpay.html +1 -0
  39. package/src/scss/components/_gift-cards.scss +32 -3
  40. package/src/scss/components/_payments-checkout.scss +2 -2
  41. package/src/scss/components/_payments-v2.scss +1 -1
  42. package/src/scss/helpers/_variables.scss +2 -0
  43. package/src/scss/pages/_checkout-confirmation-new.scss +86 -2
  44. package/src/sitemap.html +6 -0
@@ -0,0 +1 @@
1
+ !function i(o,r,s){function u(t,e){if(!r[t]){if(!o[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(a)return a(t,!0);throw(e=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",e}n=r[t]={exports:{}},o[t][0].call(n.exports,function(e){return u(o[t][1][e]||e)},n,n.exports,i,o,r,s)}return r[t].exports}for(var a="function"==typeof require&&require,e=0;e<s.length;e++)u(s[e]);return u}({1:[function(e,t,n){"use strict";var i=e("../utils/show-hide-input"),o=window.Wick||{};o.TogglePasswordVisibility={el:{$containers:$(".form-row[data-show-content] .input-wrap")},init:function(){this.el.$containers.length&&this.el.$containers.each(function(){(0,i.initializeInputToggle)($(this))})}},$(document).ready(function(){o.TogglePasswordVisibility.init()})},{"../utils/show-hide-input":2}],2:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.initializeInputToggle=function(e){var n=e.find("input"),i=e.find(".toggle-show");n.length&&i.length&&(e=function(){i.toggle(0<(n.val()||"").length)},i.off("click.passwordToggle mousedown.passwordToggle").on("mousedown.passwordToggle",function(e){e.preventDefault();var e="password"===String(n.attr("type")),t=(n.attr("type",e?"text":"password"),i.find("svg, i").first());t.length&&t.removeClass("fa-eye fa-eye-slash").addClass(e?"fa-eye":"fa-eye-slash")}),n.off("input.passwordToggle").on("input.passwordToggle",e),e())}},{}]},{},[1]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wickes-css2",
3
- "version": "2.109.0-develop.2",
3
+ "version": "2.109.0-gift-cards.1",
4
4
  "description": "CSS and JS and page templates in use by Wickes",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -40,6 +40,12 @@
40
40
  <span class="checkout-widget__detail-value">£0.00</span>
41
41
  </li>
42
42
  {{/if}}
43
+ {{#if giftCardDiscount}}
44
+ <li class="checkout-widget__item checkout-widget__item-bold checkout-widget__gift-card">
45
+ <span>Gift Card:</span>
46
+ <span class="checkout-widget__item-value">-£300.00</span>
47
+ </li>
48
+ {{/if}}
43
49
  </ul>
44
50
  {{#unless mobile}}
45
51
  <div class="checkout-widget__total" data-sticky-observe>
@@ -59,19 +59,42 @@
59
59
  <img src="./img/clearpay-logo.svg" alt="clearpay">
60
60
  </div>
61
61
  </div>
62
- {{else}}
63
- <ul class="checkout-widget__details">
62
+ {{else if giftcard}}
63
+ <div class="checkout-widget__details checkout-payment__giftcard">
64
+ <div class="checkout-widget__details__item checkout-payment__giftcard-header">
65
+ <div>Gift Card:</div>
66
+
67
+ <div class="checkout-payment__giftcard-logo">
68
+ <img src="./img/giftcard.svg" alt="giftcard">
69
+ </div>
70
+ </div>
71
+ <div class="checkout-payment__giftcard-list">
72
+ {{#each giftcards}}
73
+ <div class="checkout-widget__details__item">
74
+ <div class="checkout-payment__giftcard-label">Gift card number:</div>
75
+ <div class="checkout-payment__giftcard-value">{{this}}</div>
76
+ </div>
77
+ {{/each}}
78
+ </div>
79
+ </div>
80
+ {{/if}}
81
+ {{#if (or giftcard (not (anyOf paypal klarna billie apple google clearpay)))}}
82
+ <ul class="checkout-widget__details checkout-payment__card-details">
83
+ <li class="checkout-widget__details__item">
84
+ <span class="checkout-payment__card-label">Card type:</span>
85
+ <span class="checkout-payment__card-value">Visa</span>
86
+ </li>
64
87
  <li class="checkout-widget__details__item">
65
- <span>Card type:</span>
66
- <span>Visa</span>
88
+ <span class="checkout-payment__card-label">Card number:</span>
89
+ <span class="checkout-payment__card-value">456000*******0053</span>
67
90
  </li>
68
91
  <li class="checkout-widget__details__item">
69
- <span>Card number:</span>
70
- <span>**** **** **** 1234</span>
92
+ <span class="checkout-payment__card-label">Expiry date:</span>
93
+ <span class="checkout-payment__card-value">07/2023</span>
71
94
  </li>
72
95
  <li class="checkout-widget__details__item">
73
- <span>Expiry date:</span>
74
- <span>07/2023</span>
96
+ <span class="checkout-payment__card-label">Name on card:</span>
97
+ <span class="checkout-payment__card-value">James Smith</span>
75
98
  </li>
76
99
  </ul>
77
100
  {{/if}}
@@ -1,27 +1,20 @@
1
1
  <div class="form-row giftcard-row">
2
2
  <div class="giftcard">
3
3
  <div class="giftcard__wrapper">
4
- <span
5
- class="giftcard-add"
6
- id="giftcard-toggle"
7
- role="button"
8
- tabindex="0"
9
- aria-controls="giftcard-inline"
10
- aria-expanded="false"
11
- >
12
- <span class="icon">
13
- <i class="fas fa-plus giftcard-add__icon" aria-hidden="true"></i>
14
- </span>
15
- <span class="giftcard-add__text">Add Wickes Gift Card</span>
16
- </span>
17
- <span class="giftcard-hint">Combine with Credit/Debit card</span>
4
+ <span class="giftcard-add" id="giftcard-toggle" role="button" tabindex="0">
5
+ <span class="giftcard-add__icon-wrap" aria-hidden="true">
6
+ <i class="fas fa-plus giftcard-add__icon" aria-hidden="true"></i>
7
+ </span>
8
+ <span class="giftcard-add__text">Add Wickes Gift Card</span>
9
+ </span>
10
+ <span class="giftcard-hint">Available with Credit/Debit card only</span>
18
11
  </div>
19
12
 
20
13
  <div class="giftcard__container">
21
14
  <div class="giftcard-inline" id="giftcard-inline" hidden>
22
15
  <div class="giftcard-inline__header">
23
16
  <span class="giftcard-inline__title">Add Wickes Gift Card</span>
24
- <a href="https://www.showmybalance.com/" target="_blank" class="giftcard-inline__balance">Check balance</a>
17
+ <a href="https://wickes.showmybalance.com/" target="_blank" class="giftcard-inline__balance">Check balance</a>
25
18
  <span class="giftcard-inline__close">
26
19
  <i class="fal fa-times" aria-hidden="true"></i>
27
20
  </span>
@@ -1,16 +1,17 @@
1
1
  <div class="payways">
2
2
  <p class="payways__title">Ways to Pay</p>
3
3
  <ul class="payways__list">
4
- {{#if billieIcon}}
5
- <li class="payways__item">
6
- <img class="payways__image" src="./img/payment/footer/billie.svg" alt="Billie">
7
- </li>
8
- {{else}}
4
+ {{#if klarnaIcon}}
9
5
  <li class="payways__item">
10
6
  <img class="payways__image" src="./img/payment/footer/klarna.svg" alt="klarna">
11
7
  </span>
12
8
  </li>
13
9
  {{/if}}
10
+ {{#if billieIcon}}
11
+ <li class="payways__item">
12
+ <img class="payways__image" src="./img/payment/footer/billie.svg" alt="Billie">
13
+ </li>
14
+ {{/if}}
14
15
  {{#each payments-list}}
15
16
  <li class="payways__item">
16
17
  <img class="payways__image" src="{{src}}" alt="{{payment}}">
@@ -0,0 +1,7 @@
1
+ {
2
+ "giftcards": [
3
+ "************92712",
4
+ "************18735",
5
+ "************76946"
6
+ ]
7
+ }
@@ -77,6 +77,10 @@
77
77
  {
78
78
  "payment": "PayPal",
79
79
  "src": "./img/payment/checkout/paypal.svg"
80
+ },
81
+ {
82
+ "payment": "Gift Card",
83
+ "src": "./img/payment/checkout/giftcard.svg"
80
84
  }
81
85
  ]
82
86
  }
@@ -23,6 +23,10 @@
23
23
  {
24
24
  "payment": "PayPal",
25
25
  "src": "./img/payment/checkout/paypal.svg"
26
+ },
27
+ {
28
+ "payment": "Gift Card",
29
+ "src": "./img/payment/checkout/giftcard.svg"
26
30
  }
27
31
  ]
28
32
  }
@@ -187,6 +187,10 @@
187
187
  {
188
188
  "payment": "PayPal",
189
189
  "src": "./img/payment/footer/paypal.svg"
190
+ },
191
+ {
192
+ "payment": "Gift Card",
193
+ "src": "./img/payment/footer/giftcard.svg"
190
194
  }
191
195
  ]
192
196
  }
@@ -0,0 +1,28 @@
1
+ <svg width="36" height="23" viewBox="0 0 36 23" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g clip-path="url(#clip0_9103_110194)">
3
+ <rect width="36" height="22.5" rx="2.25" fill="white"/>
4
+ <path d="M31.875 19.5C29.625 19.125 27.375 15.75 27.375 15.75C27.375 15.75 25.5 18.75 23.25 19.5" stroke="#004587" stroke-width="1.35"/>
5
+ <path d="M22.3396 13.7778C23.0733 14.7513 24.6901 15.0189 26.4425 15.3385C26.4181 13.8977 26.0629 12.4876 25.3293 11.514C24.5957 10.5405 23.4966 10.1294 22.523 10.863C21.5495 11.5966 21.606 12.8042 22.3396 13.7778Z" fill="white" stroke="#004587" stroke-width="1.35"/>
6
+ <path d="M32.3733 13.7778C31.6396 14.7513 30.0228 15.0189 28.2703 15.3385C28.2948 13.8977 28.65 12.4876 29.3836 11.514C30.1172 10.5405 31.2163 10.1294 32.1899 10.863C33.1634 11.5966 33.1069 12.8042 32.3733 13.7778Z" fill="white" stroke="#004587" stroke-width="1.35"/>
7
+ <g clip-path="url(#clip1_9103_110194)">
8
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M2.25 0V9.15602L12.3866 11.2286L22.532 9.13257V0H2.25Z" fill="white"/>
9
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M2.92773 0.664062V8.61365L12.3876 10.5436L21.8607 8.61276V0.664062H2.92773Z" fill="#004587"/>
10
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M11.8332 5.78902C11.8267 5.56557 11.6264 5.40914 11.4047 5.40914C10.9115 5.40914 10.8341 5.82081 10.8341 6.18699C10.8341 6.52756 10.9838 6.87855 11.3563 6.87855C11.6619 6.87855 11.8167 6.70611 11.8583 6.42585H12.7143C12.6351 7.13387 12.0747 7.53996 11.3623 7.53996C10.5538 7.53996 9.95312 6.99672 9.95312 6.18699C9.95312 5.34674 10.4972 4.74609 11.3623 4.74609C12.0287 4.74609 12.6251 5.09351 12.686 5.78902H11.8332Z" fill="white"/>
11
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M12.8652 3.83203H13.7461V5.70404L14.5498 4.82462H15.5691L14.5857 5.82161L15.6932 7.46473H14.6312L13.9753 6.40141L13.7461 6.61964V7.46473H12.8652V3.83203Z" fill="white"/>
12
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M16.3009 6.35415C16.3162 6.71482 16.5282 6.95472 16.9022 6.95472C17.1135 6.95472 17.3203 6.85867 17.4044 6.66523H18.2271C18.0667 7.2766 17.491 7.53988 16.8903 7.53988C16.0166 7.53988 15.4199 7.02211 15.4199 6.13711C15.4199 5.32686 16.079 4.74609 16.8697 4.74609C17.8325 4.74609 18.3146 5.45947 18.2734 6.35415H16.3009ZM17.3928 5.87166C17.3778 5.57584 17.1651 5.33177 16.8697 5.33177C16.5594 5.33177 16.3526 5.55068 16.301 5.87166H17.3928Z" fill="white"/>
13
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M19.1879 6.59204C19.1879 6.72636 19.2428 6.82286 19.3324 6.88801C19.4145 6.94929 19.5336 6.98048 19.6585 6.98048C19.8295 6.98048 20.0734 6.91005 20.0734 6.69971C20.0734 6.49599 19.798 6.45675 19.6436 6.42071C19.0882 6.28297 18.3948 6.26592 18.3948 5.55634C18.3948 4.92099 19.0939 4.74609 19.6225 4.74609C20.2134 4.74609 20.8282 4.91504 20.86 5.60265H20.0463C20.0463 5.48933 20.0061 5.41889 19.9327 5.37154C19.8592 5.32679 19.7627 5.30482 19.6537 5.30482C19.5079 5.30482 19.276 5.32128 19.276 5.50489C19.276 5.75387 19.8658 5.79967 20.2703 5.88522C20.8122 5.99281 20.9534 6.37909 20.9534 6.59882C20.9534 7.30713 20.2703 7.53988 19.6638 7.53988C19.026 7.53988 18.3737 7.3323 18.3477 6.59204H19.1879Z" fill="white"/>
14
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M7.78099 7.46473H6.81584L6.30981 4.96222H6.29784L5.79173 7.46473H4.81408L3.81445 3.83203H4.77611L5.30124 6.48651H5.31011L5.85305 3.83203H6.75878L7.30308 6.48651H7.31323L7.83632 3.83203H8.79896L7.78099 7.46473Z" fill="white"/>
15
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M8.86499 4.49387H9.74677V3.83202H8.86499V4.49387ZM8.86499 7.46479H9.74677V4.82461H8.86499V7.46479Z" fill="white"/>
16
+ </g>
17
+ <path d="M27.375 0V16.125M27.375 22.5V16.125M27.375 16.125H35.625M27.375 16.125H0.75" stroke="#004587" stroke-width="1.35"/>
18
+ </g>
19
+ <rect x="0.375" y="0.375" width="35.25" height="21.75" rx="1.875" stroke="#CCCCCC" stroke-width="0.75"/>
20
+ <defs>
21
+ <clipPath id="clip0_9103_110194">
22
+ <rect width="36" height="22.5" rx="2.25" fill="white"/>
23
+ </clipPath>
24
+ <clipPath id="clip1_9103_110194">
25
+ <rect width="20.25" height="11.2277" fill="white" transform="translate(2.25)"/>
26
+ </clipPath>
27
+ </defs>
28
+ </svg>
@@ -0,0 +1,28 @@
1
+ <svg width="36" height="23" viewBox="0 0 36 23" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g clip-path="url(#clip0_9103_110194)">
3
+ <rect width="36" height="22.5" rx="2.25" fill="white"/>
4
+ <path d="M31.875 19.5C29.625 19.125 27.375 15.75 27.375 15.75C27.375 15.75 25.5 18.75 23.25 19.5" stroke="#004587" stroke-width="1.35"/>
5
+ <path d="M22.3396 13.7778C23.0733 14.7513 24.6901 15.0189 26.4425 15.3385C26.4181 13.8977 26.0629 12.4876 25.3293 11.514C24.5957 10.5405 23.4966 10.1294 22.523 10.863C21.5495 11.5966 21.606 12.8042 22.3396 13.7778Z" fill="white" stroke="#004587" stroke-width="1.35"/>
6
+ <path d="M32.3733 13.7778C31.6396 14.7513 30.0228 15.0189 28.2703 15.3385C28.2948 13.8977 28.65 12.4876 29.3836 11.514C30.1172 10.5405 31.2163 10.1294 32.1899 10.863C33.1634 11.5966 33.1069 12.8042 32.3733 13.7778Z" fill="white" stroke="#004587" stroke-width="1.35"/>
7
+ <g clip-path="url(#clip1_9103_110194)">
8
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M2.25 0V9.15602L12.3866 11.2286L22.532 9.13257V0H2.25Z" fill="white"/>
9
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M2.92773 0.664062V8.61365L12.3876 10.5436L21.8607 8.61276V0.664062H2.92773Z" fill="#004587"/>
10
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M11.8332 5.78902C11.8267 5.56557 11.6264 5.40914 11.4047 5.40914C10.9115 5.40914 10.8341 5.82081 10.8341 6.18699C10.8341 6.52756 10.9838 6.87855 11.3563 6.87855C11.6619 6.87855 11.8167 6.70611 11.8583 6.42585H12.7143C12.6351 7.13387 12.0747 7.53996 11.3623 7.53996C10.5538 7.53996 9.95312 6.99672 9.95312 6.18699C9.95312 5.34674 10.4972 4.74609 11.3623 4.74609C12.0287 4.74609 12.6251 5.09351 12.686 5.78902H11.8332Z" fill="white"/>
11
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M12.8652 3.83203H13.7461V5.70404L14.5498 4.82462H15.5691L14.5857 5.82161L15.6932 7.46473H14.6312L13.9753 6.40141L13.7461 6.61964V7.46473H12.8652V3.83203Z" fill="white"/>
12
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M16.3009 6.35415C16.3162 6.71482 16.5282 6.95472 16.9022 6.95472C17.1135 6.95472 17.3203 6.85867 17.4044 6.66523H18.2271C18.0667 7.2766 17.491 7.53988 16.8903 7.53988C16.0166 7.53988 15.4199 7.02211 15.4199 6.13711C15.4199 5.32686 16.079 4.74609 16.8697 4.74609C17.8325 4.74609 18.3146 5.45947 18.2734 6.35415H16.3009ZM17.3928 5.87166C17.3778 5.57584 17.1651 5.33177 16.8697 5.33177C16.5594 5.33177 16.3526 5.55068 16.301 5.87166H17.3928Z" fill="white"/>
13
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M19.1879 6.59204C19.1879 6.72636 19.2428 6.82286 19.3324 6.88801C19.4145 6.94929 19.5336 6.98048 19.6585 6.98048C19.8295 6.98048 20.0734 6.91005 20.0734 6.69971C20.0734 6.49599 19.798 6.45675 19.6436 6.42071C19.0882 6.28297 18.3948 6.26592 18.3948 5.55634C18.3948 4.92099 19.0939 4.74609 19.6225 4.74609C20.2134 4.74609 20.8282 4.91504 20.86 5.60265H20.0463C20.0463 5.48933 20.0061 5.41889 19.9327 5.37154C19.8592 5.32679 19.7627 5.30482 19.6537 5.30482C19.5079 5.30482 19.276 5.32128 19.276 5.50489C19.276 5.75387 19.8658 5.79967 20.2703 5.88522C20.8122 5.99281 20.9534 6.37909 20.9534 6.59882C20.9534 7.30713 20.2703 7.53988 19.6638 7.53988C19.026 7.53988 18.3737 7.3323 18.3477 6.59204H19.1879Z" fill="white"/>
14
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M7.78099 7.46473H6.81584L6.30981 4.96222H6.29784L5.79173 7.46473H4.81408L3.81445 3.83203H4.77611L5.30124 6.48651H5.31011L5.85305 3.83203H6.75878L7.30308 6.48651H7.31323L7.83632 3.83203H8.79896L7.78099 7.46473Z" fill="white"/>
15
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M8.86499 4.49387H9.74677V3.83202H8.86499V4.49387ZM8.86499 7.46479H9.74677V4.82461H8.86499V7.46479Z" fill="white"/>
16
+ </g>
17
+ <path d="M27.375 0V16.125M27.375 22.5V16.125M27.375 16.125H35.625M27.375 16.125H0.75" stroke="#004587" stroke-width="1.35"/>
18
+ </g>
19
+ <rect x="0.375" y="0.375" width="35.25" height="21.75" rx="1.875" stroke="#CCCCCC" stroke-width="0.75"/>
20
+ <defs>
21
+ <clipPath id="clip0_9103_110194">
22
+ <rect width="36" height="22.5" rx="2.25" fill="white"/>
23
+ </clipPath>
24
+ <clipPath id="clip1_9103_110194">
25
+ <rect width="20.25" height="11.2277" fill="white" transform="translate(2.25)"/>
26
+ </clipPath>
27
+ </defs>
28
+ </svg>
@@ -10,22 +10,110 @@ Wick.CheckoutPaymentDetails = (function () {
10
10
  buttonName: 'btn-enter-details',
11
11
  };
12
12
 
13
- const elements = {
14
- $billieRepaymentTerms: $('.js-billie-repayment-terms'),
15
- $billieInfoBlock: $('.checkout-payment-details__billie'),
16
- $billieInfo: $('.checkout-payment-details__billie .billie-info'),
17
- $wrapperPaymentInput: $('.checkout-payment-details__row'),
18
- paymentInputName: '[name=payment-method]',
19
- $cardDetails: $('.checkout-payment-details__card-details'),
20
- $placeOrder: $('.checkout-payment-details__place-order'),
21
- $billingAddress: $('.billing-address'),
22
- hiddenCardDetailsClass: 'checkout-payment-details__card-details_hidden',
23
- $billieBusiness: $('[data-billie-business]'),
24
- businessTypeName: '[name="businessType"]',
25
- $unregisteredFields: $('#unregistered-fields'),
26
- $registeredFields: $('#registered-fields'),
27
- hiddenClass: 'd-none',
28
- };
13
+ const elements = {
14
+ $billieRepaymentTerms: $('.js-billie-repayment-terms'),
15
+ $billieWidget: $('.checkout-payment-details__billie[data-billie]'),
16
+ $wrapperPaymentInput: $('.checkout-payment-details__row'),
17
+ paymentInputName: '[name=payment-method]',
18
+ $cardDetails: $('.checkout-payment-details__card-details'),
19
+ $placeOrder: $('.checkout-payment-details__place-order'),
20
+ $billingAddress: $('.billing-address'),
21
+ hiddenCardDetailsClass: 'checkout-payment-details__card-details_hidden',
22
+ $billieBusiness: $('[data-billie-business]'),
23
+ businessTypeName: '[name="businessType"]',
24
+ $unregisteredFields: $('#unregistered-fields'),
25
+ $registeredFields: $('#registered-fields'),
26
+ hiddenClass: 'd-none',
27
+ $giftcardToggle: $('#giftcard-toggle'),
28
+ $giftcardPanel: $('#giftcard-inline'),
29
+ giftcardDisabledClass: 'giftcard-toggle--disabled',
30
+ giftcardRoot: '.giftcard',
31
+ giftcardHint: '.giftcard-hint',
32
+ giftcardNumber: 'input[name="giftcard-number"]',
33
+ giftcardPin: 'input[name="giftcard-pin"]',
34
+ }
35
+
36
+ function setGiftcardToggleEnabled(isEnabled) {
37
+ const $toggle = elements.$giftcardToggle;
38
+ const $panel = elements.$giftcardPanel;
39
+ const $giftcard = $toggle.closest('.giftcard');
40
+
41
+ if (!$toggle.length) {
42
+ return;
43
+ }
44
+
45
+ $giftcard.toggleClass('giftcard--disabled', !isEnabled);
46
+
47
+ if (isEnabled) {
48
+ $toggle
49
+ .attr('aria-disabled', 'false')
50
+ .attr('tabindex', '0')
51
+ .css('pointer-events', '');
52
+ } else {
53
+ if ($panel && $panel.length) $panel.prop('hidden', true);
54
+
55
+ $toggle
56
+ .attr('aria-disabled', 'true')
57
+ .attr('tabindex', '-1')
58
+ .css('pointer-events', 'none')
59
+ .attr('aria-expanded', 'false')
60
+ .show();
61
+
62
+ $giftcard.find('.giftcard-hint').show();
63
+ }
64
+ }
65
+
66
+
67
+ function resetGiftcardToDefault() {
68
+ const {
69
+ $giftcardToggle: $toggle,
70
+ $giftcardPanel: $panel,
71
+ giftcardRoot,
72
+ giftcardHint,
73
+ giftcardNumber,
74
+ giftcardPin,
75
+ } = elements;
76
+
77
+ if (!$toggle.length) {
78
+ return;
79
+ }
80
+
81
+ const $giftcard = $toggle.closest(giftcardRoot);
82
+
83
+ const $hint = $giftcard.find(giftcardHint);
84
+ const $number = $giftcard.find(giftcardNumber);
85
+ const $pin = $giftcard.find(giftcardPin);
86
+
87
+ if ($panel.length) $panel.prop('hidden', true);
88
+
89
+ $toggle.attr('aria-expanded', 'false').show();
90
+ $hint.show();
91
+
92
+ if (window.Wick?.GiftCard?.resetForm) {
93
+ Wick.GiftCard.resetForm($giftcard);
94
+ return;
95
+ }
96
+
97
+ $number.val('');
98
+ $pin.val('');
99
+ }
100
+
101
+ function syncGiftcardAvailability(checkedMethod) {
102
+ const enable = checkedMethod === 'card';
103
+
104
+ if (!enable) {
105
+ const $giftcard = elements.$giftcardToggle.closest(elements.giftcardRoot);
106
+ if (window.Wick?.GiftCard?.collapsePreserveState) {
107
+ Wick.GiftCard.collapsePreserveState($giftcard);
108
+ } else {
109
+ if (elements.$giftcardPanel.length) elements.$giftcardPanel.prop('hidden', true);
110
+ elements.$giftcardToggle.attr('aria-expanded', 'false').show();
111
+ $giftcard.find(elements.giftcardHint).show();
112
+ }
113
+ }
114
+
115
+ setGiftcardToggleEnabled(enable);
116
+ }
29
117
 
30
118
  function preparePage() {
31
119
  var modalOpened = $('.modal.show').length;
@@ -57,29 +145,36 @@ Wick.CheckoutPaymentDetails = (function () {
57
145
  paymentMethods.forEach((method) => {
58
146
  $(`[data-${method}]`).toggle(checkedMethod === method);
59
147
  });
148
+ const $selected = $(`[data-${checkedMethod}]`);
149
+ if ($selected.length) {
150
+ $selected.show();
151
+ }
60
152
  }
61
153
 
62
- function resetAllCheckoutForms(keepPaymentMethod) {
63
- const $container = elements.$wrapperPaymentInput.closest('.checkout-payment-details');
64
- if (!$container.length) return;
154
+ function resetAllCheckoutForms(keepPaymentMethod) {
155
+ const $container = elements.$wrapperPaymentInput.closest('.checkout-payment-details');
156
+ if (!$container.length) return;
157
+ const $giftcardScope = $container.find(elements.giftcardRoot);
158
+ const $exclude = $giftcardScope.find(':input');
65
159
 
66
- $container.find('form').each(function () {
67
- if (Wick.Forms && typeof Wick.Forms.clearValidationErrors === 'function') {
68
- Wick.Forms.clearValidationErrors(this);
69
- }
70
- });
160
+ $container.find('form').each(function() {
161
+ if ($(this).closest(elements.giftcardRoot).length) return;
71
162
 
72
- $container
73
- .find(
74
- 'input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="password"], textarea'
75
- )
76
- .val('');
163
+ if (Wick.Forms && typeof Wick.Forms.clearValidationErrors === 'function') {
164
+ Wick.Forms.clearValidationErrors(this);
165
+ }
166
+ });
77
167
 
78
- $container.find('select').each(function () {
79
- this.selectedIndex = 0;
80
- });
168
+ $container
169
+ .find('input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="password"], textarea')
170
+ .not($exclude)
171
+ .val('');
81
172
 
82
- $container.find('input[type="checkbox"]').prop('checked', false);
173
+ $container.find('select').not($exclude).each(function() {
174
+ this.selectedIndex = 0;
175
+ });
176
+
177
+ $container.find('input[type="checkbox"]').not($exclude).prop('checked', false);
83
178
 
84
179
  $container.find('input[type="radio"]').each(function () {
85
180
  const $radio = $(this);
@@ -222,34 +317,36 @@ Wick.CheckoutPaymentDetails = (function () {
222
317
  buttonElement && buttonElement.text(buttonText);
223
318
  }
224
319
 
225
- function clearInputFields() {
226
- elements.$billingAddress.find('input.tbx').val('');
227
- }
228
-
229
- function showPlaceOrder() {
230
- elements.$placeOrder.removeClass(elements.hiddenClass);
231
- }
232
-
233
- function hidePlaceOrder() {
234
- elements.$placeOrder.addClass(elements.hiddenClass);
235
- }
236
-
237
- function initBillieBusinessTypeToggle() {
238
- $(document).on('change', elements.businessTypeName, function () {
239
- toggleBusinessTypeFields($(this).val());
240
- });
241
- }
242
-
243
- function forceReflow($element) {
244
- if (!$element.length) return;
245
- void $element[0].offsetHeight;
246
- $(window).trigger('resize');
247
- }
248
-
249
- function init() {
250
- const paymentMethods = getPaymentMethods();
251
- initBillieBusinessTypeToggle();
252
- hideBillieBusiness();
320
+ function clearInputFields() {
321
+ elements.$billingAddress.find('input.tbx').val('');
322
+ }
323
+
324
+ function showPlaceOrder() {
325
+ elements.$placeOrder.removeClass(elements.hiddenClass);
326
+ }
327
+
328
+ function hidePlaceOrder() {
329
+ elements.$placeOrder.addClass(elements.hiddenClass);
330
+ }
331
+
332
+ function initBillieBusinessTypeToggle() {
333
+ $(document).on('change', elements.businessTypeName, function () {
334
+ toggleBusinessTypeFields($(this).val());
335
+ });
336
+ }
337
+
338
+ function forceReflow($element) {
339
+ if (!$element.length) return;
340
+ void $element[0].offsetHeight;
341
+ $(window).trigger('resize');
342
+ }
343
+
344
+ function init() {
345
+ const paymentMethods = getPaymentMethods();
346
+ const initialMethod = $(elements.paymentInputName + ':checked').val() || 'card';
347
+ syncGiftcardAvailability(initialMethod);
348
+ initBillieBusinessTypeToggle();
349
+ hideBillieBusiness();
253
350
 
254
351
  $(document).on('change', 'input[name="repaymentTerms"]', function () {
255
352
  const currentMethod = $(elements.paymentInputName + ':checked').val();
@@ -269,27 +366,27 @@ Wick.CheckoutPaymentDetails = (function () {
269
366
  elements.$wrapperPaymentInput.on('change', elements.paymentInputName, function () {
270
367
  const checkedMethod = $(this).val();
271
368
 
272
- if (prevPaymentMethod && prevPaymentMethod !== checkedMethod) {
273
- resetAllCheckoutForms(checkedMethod);
274
- } else {
275
- const form = $(this).closest('form')[0];
276
- form &&
277
- Wick.Forms &&
278
- Wick.Forms.clearValidationErrors &&
279
- Wick.Forms.clearValidationErrors(form);
280
- }
369
+ togglePaymentBlocks(paymentMethods, checkedMethod)
370
+ changeDetailsBlock(checkedMethod)
371
+ syncGiftcardAvailability(checkedMethod);
281
372
 
282
- togglePaymentBlocks(paymentMethods, checkedMethod);
283
- changeDetailsBlock(checkedMethod);
373
+ if (prevPaymentMethod && prevPaymentMethod !== checkedMethod) {
374
+ resetAllCheckoutForms(checkedMethod);
375
+ } else {
376
+ const form = $(this).closest('form')[0];
377
+ form && Wick.Forms && Wick.Forms.clearValidationErrors && Wick.Forms.clearValidationErrors(form);
378
+ }
284
379
 
285
- prevPaymentMethod = checkedMethod;
286
- });
380
+ prevPaymentMethod = checkedMethod;
381
+ });
287
382
 
288
- $('.btn-new-card').on('click', function () {
289
- $('[data-new-card]').show();
290
- $('[data-existing-card]').hide();
291
- return false;
292
- });
383
+ $('.btn-new-card').on('click', function() {
384
+ elements.$cardDetails.removeClass(elements.hiddenCardDetailsClass);
385
+
386
+ $('[data-new-card]').show();
387
+ $('[data-existing-card]').hide();
388
+ return false;
389
+ });
293
390
 
294
391
  $('.btn-back-to-existing-card').on('click', function () {
295
392
  $('[data-new-card]').hide();