PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / trunk
Booking for Appointments and Events Calendar – Amelia vtrunk
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / public / js / wc / checkout.js
ameliabooking / public / js / wc Last commit date
checkout.js 1 month ago
checkout.js
79 lines
1 function setAmeliaFieldValue(selector, value) {
2 let element = document.querySelector(selector);
3
4 if (typeof element !== 'undefined' && element) {
5 const valueSetter = Object.getOwnPropertyDescriptor(element, 'value').set;
6 const prototype = Object.getPrototypeOf(element);
7 const prototypeValueSetter = Object.getOwnPropertyDescriptor(prototype, 'value').set;
8
9 if (valueSetter && valueSetter !== prototypeValueSetter) {
10 prototypeValueSetter.call(element, value);
11 } else {
12 valueSetter.call(element, value);
13 }
14
15 element.dispatchEvent(new Event('input', { bubbles: true }));
16 }
17 }
18
19 document.addEventListener('DOMContentLoaded', function() {
20 if ('ameliaCustomer' in window) {
21 let ameliaCustomerInterval = setInterval(
22 function () {
23 if (document.body.classList.contains('woocommerce-checkout')) {
24 clearInterval(ameliaCustomerInterval);
25
26 Object.keys(ameliaCustomer).forEach((key) => {
27 setAmeliaFieldValue('#' + key, ameliaCustomer[key]);
28 })
29 }
30 }, 500
31 )
32
33 const injectItemContent = (block, index) => {
34 let el = block.querySelector('.wc-block-components-product-details');
35
36 if (el !== null && 'ameliaNote' + index in window && !el.querySelector('.amelia-custom-html')) {
37 const div = document.createElement('div');
38 div.className = 'amelia-custom-html';
39 div.innerHTML = '<div>' + window['ameliaNote' + index][0] + '</div>';
40 el.appendChild(div);
41 }
42 }
43
44 const injectCustomContent = () => {
45 document.querySelectorAll('.wc-block-cart-items__row').forEach((block, index) => {
46 injectItemContent(block, index)
47 });
48
49 document.querySelectorAll('.wc-block-components-order-summary-item').forEach((block, index) => {
50 injectItemContent(block, index)
51 });
52 };
53
54 injectCustomContent();
55
56 // Use MutationObserver to handle async block rendering
57 const observer = new MutationObserver(injectCustomContent);
58 observer.observe(document.body, { childList: true, subtree: true });
59 }
60 });
61
62 const ameliaStyleTag = document.createElement('style');
63
64 ameliaStyleTag.innerHTML = `
65 .wc-block-components-product-details__appointment-info {
66 display: none
67 }
68
69 .wc-block-components-product-details__event-info {
70 display: none
71 }
72
73 .wc-block-components-product-details__package-info {
74 display: none
75 }
76 `;
77
78 document.head.appendChild(ameliaStyleTag);
79