PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.8
Booking for Appointments and Events Calendar – Amelia v2.4.8
2.4.8 2.4.7 2.4.6 2.4.5 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 / v3 / src / assets / js / public / cart.js
ameliabooking / v3 / src / assets / js / public Last commit date
actions.js 1 month ago booking.js 2 days ago cabinet.js 1 month ago cart.js 2 days ago catalog.js 2 days ago coupon.js 1 month ago customFields.js 1 month ago customFontFace.js 1 month ago eventFormCssVars.js 1 month ago events.js 1 month ago facebookPixel.js 1 month ago ivy.js 1 month ago package.js 2 days ago panel.js 1 month ago public.js 1 month ago renderActions.js 1 month ago restore.js 2 days ago slots.js 2 days ago stripePaymentIntent.js 2 days ago translation.js 1 month ago user.js 1 month ago
cart.js
187 lines
1 import { settings } from '../../../plugins/settings'
2
3 function useCart(store) {
4 return store.getters['booking/getAllMultipleAppointments']
5 }
6
7 function useCartItem(store) {
8 return store.getters['booking/getAllMultipleAppointments'][
9 store.getters['booking/getCartItemIndex']
10 ]
11 }
12
13 function useCartHasItems(store) {
14 let cart = useCart(store)
15
16 let hasItems = 0
17
18 cart.forEach((item) => {
19 if (!item.packageId) {
20 Object.keys(item.services).forEach((serviceId) => {
21 if (item.services[serviceId].list.filter((i) => i.date && i.time && i.providerId).length) {
22 hasItems++
23 }
24 })
25 }
26 })
27
28 return hasItems
29 }
30
31 function useCartStep(store) {
32 let preselected = store.getters['entities/getPreselected']
33
34 return (
35 settings.payments.cart &&
36 !(
37 preselected.show === 'packages' ||
38 (Array.isArray(preselected.package) ? preselected.package.length : preselected.package)
39 )
40 )
41 }
42
43 function useAddToCart(store) {
44 let index = store.getters['booking/getCartItemIndex']
45
46 let items = store.getters['booking/getAllMultipleAppointments']
47
48 index++
49
50 items[index] = {
51 packageId: null,
52 serviceId: null,
53 index: 0,
54 services: {},
55 }
56
57 store.commit('booking/setCartItemIndex', index)
58 }
59
60 function useGoToCartStep(stepsArray, stepIndex) {
61 stepIndex.value = stepsArray.value.findIndex((i) => i.name === 'CartStep')
62 }
63
64 function useInitSelection(store, deselectService) {
65 let preselected = store.getters['entities/getPreselected']
66
67 if (deselectService && !preselected.service.length) {
68 store.commit('booking/setServiceId', null)
69 store.commit('booking/setCategoryId', null)
70 }
71
72 if (!preselected.employee.length) {
73 store.commit('booking/setEmployeeId', null)
74 }
75
76 if (!preselected.location.length) {
77 store.commit('booking/setLocationId', null)
78 }
79
80 if (!preselected.package.length) {
81 store.commit('booking/setPackageId', null)
82
83 store.commit('booking/setBookableType', 'appointment')
84 }
85 }
86
87 function useResetCart(store) {
88 let items = store.getters['booking/getAllMultipleAppointments']
89
90 if (items[0].packageId) {
91 store.commit('booking/setMultipleAppointments', [
92 {
93 packageId: null,
94 serviceId: null,
95 index: 0,
96 services: {},
97 },
98 ])
99 }
100 }
101
102 function useInitCartItem(store) {
103 let index = store.getters['booking/getCartItemIndex']
104
105 let items = store.getters['booking/getAllMultipleAppointments']
106
107 let serviceId = store.getters['booking/getServiceId']
108
109 let appointmentInstantiated = index in items && serviceId in items[index].services
110
111 if (
112 serviceId &&
113 items[index] &&
114 'services' in items[index] &&
115 !(serviceId in items[index].services)
116 ) {
117 items[index].index = 0
118
119 items[index].packageId = null
120
121 items[index].serviceId = serviceId
122
123 items[index].services = {}
124
125 items[index].services[serviceId] = {
126 fetched: false,
127 slots: [],
128 busyness: {},
129 providerId: store.getters['booking/getEmployeeId'],
130 locationId: store.getters['booking/getLocationId'],
131 list: [
132 {
133 providerId: store.getters['booking/getEmployeeId'],
134 locationId: store.getters['booking/getLocationId'],
135 date: appointmentInstantiated
136 ? store.getters['booking/getMultipleAppointmentsDate']
137 : null,
138 time: appointmentInstantiated
139 ? store.getters['booking/getMultipleAppointmentsTime']
140 : null,
141 range: appointmentInstantiated
142 ? store.getters['booking/getMultipleAppointmentsRange']
143 : { start: null, end: null },
144 persons: 1,
145 extras: [],
146 duration: null,
147 price: null,
148 },
149 ],
150 }
151 } else if (!serviceId) {
152 items[index].index = ''
153
154 items[index].services = {}
155
156 items[index].packageId = null
157
158 items[index].serviceId = null
159 }
160 }
161
162 function useRemoveLastCartItem(store) {
163 let items = store.getters['booking/getAllMultipleAppointments']
164
165 if (
166 !items[items.length - 1].services[items[items.length - 1].serviceId].list[0].date &&
167 !items[items.length - 1].services[items[items.length - 1].serviceId].list[0].time
168 ) {
169 items.pop()
170
171 store.commit('booking/setCartItemIndex', items.length - 1)
172 }
173 }
174
175 export {
176 useInitSelection,
177 useAddToCart,
178 useGoToCartStep,
179 useCartHasItems,
180 useInitCartItem,
181 useCartStep,
182 useCart,
183 useResetCart,
184 useCartItem,
185 useRemoveLastCartItem,
186 }
187