PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.18
Booktics – Appointment Booking Calendar for Service Businesses v1.0.18
1.0.29 1.0.28 1.0.27 1.0.26 1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 All 31 releases
booktics / core / admin / notification.php

notification.php in Booktics – Appointment Booking Calendar for Service Businesses 1.0.18, at core/admin/notification.php

438 lines 13.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Booktics\Admin;
4
5 if ( ! defined( 'ABSPATH' ) ) exit;
6
7 use Booktics\Contracts\Hookable_Service_Contract;
8 use Ens\Core\SDK;
9
10 class Notification implements Hookable_Service_Contract {
11
12 /**
13 * Register notification
14 *
15 * @return void
16 */
17 public function register() {
18 if ( class_exists( SDK::class ) ) {
19 add_filter( 'notification_sdk_email_body', [ $this, 'wrap_email_body' ], 10, 1 );
20
21 SDK::get_instance()
22 ->setup(
23 array(
24 'plugin_name' => 'Booktics',
25 'plugin_slug' => 'booktics',
26 'general_prefix' => 'bt',
27 'text_domain' => 'booktics',
28 'admin_script_handler' => 'booktics-dashboard-scripts',
29 'sub_menu_filter_hook' => 'booktics_menu',
30 'sub_menu_details' =>
31 array(
32 'id' => 'booktics-automation',
33 'title' => __( 'Automation', 'booktics' ),
34 'link' => '/automation',
35 'capability' => apply_filters( 'booktics_menu_permission_automation_dashboard', 'manage_options' ),
36 'position' => apply_filters( 'booktics_menu_position_automation', 11 ),
37 ),
38 )
39 )
40 ->init();
41
42 add_filter(
43 'ens_bt_available_actions', function ( $actions ) {
44 $actions = array(
45 array(
46 'trigger_label' => __( 'Order Created', 'booktics' ),
47 'trigger_value' => 'order_created',
48 'trigger_data' => array(
49 array(
50 'label' => __( 'Order No', 'booktics' ),
51 'value' => 'order_no',
52 'type' => 'string',
53 ),
54 array(
55 'label' => __( 'Order Status', 'booktics' ),
56 'value' => 'order_status',
57 'type' => 'string',
58 ),
59 array(
60 'label' => __( 'Order Date', 'booktics' ),
61 'value' => 'order_date',
62 'type' => 'date',
63 ),
64 array(
65 'label' => __( 'Service Name', 'booktics' ),
66 'value' => 'service_name',
67 'type' => 'string',
68 ),
69 array(
70 'label' => __( 'Team Name', 'booktics' ),
71 'value' => 'team_name',
72 'type' => 'string',
73 ),
74 array(
75 'label' => __( 'Appointment Date', 'booktics' ),
76 'value' => 'appointment_date',
77 'type' => 'date',
78 ),
79 array(
80 'label' => __( 'Appointment Status', 'booktics' ),
81 'value' => 'appointment_status',
82 'type' => 'string',
83 ),
84 array(
85 'label' => __( 'Start Time', 'booktics' ),
86 'value' => 'start_time',
87 'type' => 'string',
88 ),
89 array(
90 'label' => __( 'End Time', 'booktics' ),
91 'value' => 'end_time',
92 'type' => 'string',
93 ),
94 array(
95 'label' => __( 'Location Address', 'booktics' ),
96 'value' => 'location_address',
97 'type' => 'string',
98 ),
99 array(
100 'label' => __( 'Order Total', 'booktics' ),
101 'value' => 'order_total',
102 'type' => 'string',
103 ),
104 array(
105 'label' => __( 'Customer Name', 'booktics' ),
106 'value' => 'customer_name',
107 'type' => 'string',
108 ),
109 array(
110 'label' => __( 'Google meet Url', 'booktics' ),
111 'value' => 'google_meet_url',
112 'type' => 'string',
113 ),
114 array(
115 'label' => __( 'Appointment Reschedule Url', 'booktics' ),
116 'value' => 'appointment_reschedule_url',
117 'type' => 'string',
118 ),
119 array(
120 'label' => __( 'Appointment Cancel Url', 'booktics' ),
121 'value' => 'appointment_cancel_url',
122 'type' => 'string',
123 ),
124 array(
125 'label' => __( 'User Email', 'booktics' ),
126 'value' => 'user_email',
127 'type' => 'string',
128 ),
129 ),
130 'delay_dependencies' => array(
131 array(
132 'label' => 'Order Date',
133 'value' => 'order_date',
134 ),
135 ),
136 'email_receivers' => array(
137 array(
138 'label' => __( 'User Email', 'booktics' ),
139 'value' => 'user_email',
140 ),
141 ),
142 ),
143 array(
144 'trigger_label' => __( 'Appointment Scheduled', 'booktics' ),
145 'trigger_value' => 'appointment_scheduled',
146 'trigger_data' => array(
147 array(
148 'label' => __( 'Service Name', 'booktics' ),
149 'value' => 'appointment_service',
150 'type' => 'string',
151 ),
152 array(
153 'label' => __( 'Team Member Name', 'booktics' ),
154 'value' => 'appointment_team_member',
155 'type' => 'string',
156 ),
157 array(
158 'label' => __( 'Appointment Date', 'booktics' ),
159 'value' => 'appointment_date',
160 'type' => 'date',
161 ),
162 array(
163 'label' => __( 'Appointment Start Time', 'booktics' ),
164 'value' => 'start_time',
165 'type' => 'string',
166 ),
167 array(
168 'label' => __( 'Appointment Time', 'booktics' ),
169 'value' => 'appointment_time',
170 'type' => 'date',
171 ),
172 array(
173 'label' => __( 'Attendee Count', 'booktics' ),
174 'value' => 'attendee_count',
175 'type' => 'string',
176 ),
177 array(
178 'label' => __( 'Customer Name', 'booktics' ),
179 'value' => 'customer_name',
180 'type' => 'string',
181 ),
182 array(
183 'label' => __( 'User Email', 'booktics' ),
184 'value' => 'user_email',
185 'type' => 'string',
186 ),
187 array(
188 'label' => __( 'Google Meet URL', 'booktics' ),
189 'value' => 'google_meet_url',
190 'type' => 'string',
191 ),
192 array(
193 'label' => __( 'Extra Services', 'booktics' ),
194 'value' => 'extra_services',
195 'type' => 'string',
196 ),
197 ),
198 'delay_dependencies' => array(
199 array(
200 'label' => __( 'Appointment Time', 'booktics' ),
201 'value' => 'before_appointment_time',
202 ),
203 ),
204 'email_receivers' => array(
205 array(
206 'label' => __( 'User Email', 'booktics' ),
207 'value' => 'user_email',
208 ),
209 array(
210 'label' => __( 'Team Member Email', 'booktics' ),
211 'value' => 'appointment_team_member_email',
212 ),
213 ),
214 ),
215 array(
216 'trigger_label' => __( 'Appointment Rescheduled', 'booktics' ),
217 'trigger_value' => 'appointment_rescheduled',
218 'trigger_data' => array(
219 array(
220 'label' => __( 'Service Name', 'booktics' ),
221 'value' => 'appointment_service',
222 'type' => 'string',
223 ),
224 array(
225 'label' => __( 'Date', 'booktics' ),
226 'value' => 'date',
227 'type' => 'date',
228 ),
229 array(
230 'label' => __( 'Team Member Name', 'booktics' ),
231 'value' => 'appointment_team_member',
232 'type' => 'string',
233 ),
234 array(
235 'label' => __( 'Start Time', 'booktics' ),
236 'value' => 'start_time',
237 'type' => 'string',
238 ),
239 array(
240 'label' => __( 'End Time', 'booktics' ),
241 'value' => 'end_time',
242 'type' => 'string',
243 ),
244 array(
245 'label' => __( 'Customer Name', 'booktics' ),
246 'value' => 'customer_name',
247 'type' => 'string',
248 ),
249 array(
250 'label' => __( 'User Email', 'booktics' ),
251 'value' => 'user_email',
252 'type' => 'string',
253 ),
254 ),
255 'delay_dependencies' => array(
256 array(
257 'label' => __( 'Date', 'booktics' ),
258 'value' => 'date',
259 ),
260 ),
261 'email_receivers' => array(
262 array(
263 'label' => __( 'User Email', 'booktics' ),
264 'value' => 'user_email',
265 ),
266 array(
267 'label' => __( 'Team Member Email', 'booktics' ),
268 'value' => 'appointment_team_member_email',
269 ),
270 ),
271 ),
272 array(
273 'trigger_label' => __( 'Appointment Cancelled', 'booktics' ),
274 'trigger_value' => 'appointment_cancelled',
275 'trigger_data' => array(
276 array(
277 'label' => __( 'Service Name', 'booktics' ),
278 'value' => 'appointment_service',
279 'type' => 'string',
280 ),
281 array(
282 'label' => __( 'Date', 'booktics' ),
283 'value' => 'date',
284 'type' => 'date',
285 ),
286 array(
287 'label' => __( 'Team Member Name', 'booktics' ),
288 'value' => 'appointment_team_member',
289 'type' => 'string',
290 ),
291 array(
292 'label' => __( 'Start Time', 'booktics' ),
293 'value' => 'start_time',
294 'type' => 'string',
295 ),
296 array(
297 'label' => __( 'End Time', 'booktics' ),
298 'value' => 'end_time',
299 'type' => 'string',
300 ),
301 array(
302 'label' => __( 'Customer Name', 'booktics' ),
303 'value' => 'customer_name',
304 'type' => 'string',
305 ),
306 array(
307 'label' => __( 'User Email', 'booktics' ),
308 'value' => 'user_email',
309 'type' => 'string',
310 ),
311 ),
312 'delay_dependencies' => array(
313 array(
314 'label' => __( 'Date', 'booktics' ),
315 'value' => 'date',
316 ),
317 ),
318 'email_receivers' => array(
319 array(
320 'label' => __( 'User Email', 'booktics' ),
321 'value' => 'user_email',
322 ),
323 array(
324 'label' => __( 'Team Member Email', 'booktics' ),
325 'value' => 'appointment_team_member_email',
326 ),
327 ),
328 ),
329 array(
330 'trigger_label' => __( 'Team Member Created', 'booktics' ),
331 'trigger_value' => 'team_member_created',
332 'trigger_data' => array(
333 array(
334 'label' => __( 'Team Member Name', 'booktics' ),
335 'value' => 'team_member_name',
336 'type' => 'string',
337 ),
338 array(
339 'label' => __( 'Team Member Email', 'booktics' ),
340 'value' => 'team_member_email',
341 'type' => 'string',
342 ),
343 array(
344 'label' => __( 'Password Reset URL', 'booktics' ),
345 'value' => 'password_reset_url',
346 'type' => 'string',
347 ),
348 ),
349 'delay_dependencies' => array(),
350 'email_receivers' => array(
351 array(
352 'label' => __( 'Team Member Email', 'booktics' ),
353 'value' => 'team_member_email',
354 ),
355 ),
356 ),
357 array(
358 'trigger_label' => __( 'Customer Created', 'booktics' ),
359 'trigger_value' => 'customer_created',
360 'trigger_data' => array(
361 array(
362 'label' => __( 'Customer First Name', 'booktics' ),
363 'value' => 'customer_first_name',
364 'type' => 'string',
365 ),
366 array(
367 'label' => __( 'Customer Last Name', 'booktics' ),
368 'value' => 'customer_last_name',
369 'type' => 'string',
370 ),
371 array(
372 'label' => __( 'Customer Full Name', 'booktics' ),
373 'value' => 'customer_full_name',
374 'type' => 'string',
375 ),
376 array(
377 'label' => __( 'Customer Phone', 'booktics' ),
378 'value' => 'customer_phone',
379 'type' => 'string',
380 ),
381 array(
382 'label' => __( 'Customer User Name', 'booktics' ),
383 'value' => 'customer_user_name',
384 'type' => 'string',
385 ),
386 array(
387 'label' => __( 'Customer Email', 'booktics' ),
388 'value' => 'customer_email',
389 'type' => 'string',
390 ),
391 array(
392 'label' => __( 'Password Reset URL', 'booktics' ),
393 'value' => 'password_reset_url',
394 'type' => 'string',
395 ),
396 ),
397 'delay_dependencies' => array(),
398 'email_receivers' => array(
399 array(
400 'label' => __( 'Customer Email', 'booktics' ),
401 'value' => 'customer_email',
402 ),
403 ),
404 ),
405 );
406
407 return $actions;
408 }
409 );
410 }
411 }
412
413 /**
414 * Wrap email body with custom template
415 *
416 * @param string $message
417 * @return string
418 */
419 public function wrap_email_body( $message ) {
420
421 $template_path = BOOKTICS_DIR . '/templates/email/team-member-create.html';
422
423 if ( ! file_exists( $template_path ) ) {
424 return $message;
425 }
426 $template = file_get_contents( $template_path );
427 $default_image = get_template_directory_uri() . '/assets/images/placeholder.jpg';
428 $variables = array(
429 '{{MESSAGE}}' => wp_kses_post( $message ),
430 '{{COMPANY_NAME}}' => booktics_get_option( 'business_name', get_bloginfo( 'name' ) ),
431 '{{COMPANY_LOGO}}' => booktics_get_option( 'business_logo', $default_image ),
432 '{{COMPANY_ADDRESS}}' => booktics_get_option( 'business_address', 'California, USA' ),
433 );
434
435 return str_replace( array_keys( $variables ), array_values( $variables ), $template );
436 }
437 }
438