Created
May 14, 2026 13:54
-
-
Save Crocoblock/2369fffd39343257338563466320afdb to your computer and use it in GitHub Desktop.
JetFormBuilder / JetAppointments - get the number of Slots and Hours from appointment calendar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| document.addEventListener("DOMContentLoaded", function () { | |
| if (!window?.JetPlugins?.hooks) { | |
| return; | |
| } | |
| const { addAction } = JetPlugins.hooks; | |
| addAction( | |
| "jet.fb.input.makeReactive", | |
| "jet-form-builder/jet-appointments-booking/custom-get-count", | |
| function (input) { | |
| if (!input?.nodes?.length) { | |
| return; | |
| } | |
| if (input.nodes[0]?.attributes['data-field']?.value == 'appointment') { | |
| input.watch(() => { | |
| let countSlots = [], countTime = [], dates = []; | |
| const formId = input.root.rootNode.dataset.formId, | |
| appointments = input.nodes[0].value ? JSON.parse(input.nodes[0].value) : []; | |
| appointments.forEach(element => { | |
| countTime.push((element.slotEnd - element.slot) / 60 * (element.count || 1)); | |
| countSlots.push(element.count || 1); | |
| dates.push(element.date || ''); | |
| }); | |
| if (window.JetFormBuilder[formId].dataInputs?._jet_app_count_slots) { | |
| window.JetFormBuilder[formId].dataInputs._jet_app_count_slots.value.current = countSlots.reduce((accumulator, currentValue) => accumulator + currentValue, 0); | |
| } | |
| if (window.JetFormBuilder[formId].dataInputs?._jet_app_count_time) { | |
| window.JetFormBuilder[formId].dataInputs._jet_app_count_time.value.current = countTime.reduce((accumulator, currentValue) => accumulator + currentValue, 0); | |
| } | |
| if (window.JetFormBuilder[formId].dataInputs?._jet_app_date) { | |
| window.JetFormBuilder[formId].dataInputs._jet_app_date.value.current = dates.join(', '); | |
| } | |
| }); | |
| } | |
| } | |
| ); | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result: https://i.imgur.com/gGDdRXp.png